rajeeshvr_80 Posted November 1, 2007 Share Posted November 1, 2007 Hi All, I have a problem in my Arabic emails.They are not encoding properly.I am using the MIME version 1.0, function getheader_email($from_email){ $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $headers .= "From: <".$from_email.">" . "\r\n"; return $headers; } function format_html($html){ return "<html><body><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><font style=\"font-family:Arial, Helvetica, sans-serif; font-size:10px\">$html</font></body></html>"; } and I am using the mail() function for send the emails. mail(str_replace(' ','',$ownuser_email),$arrlangconst["OWN_DELVIDEO_MAILSUBJECT"],$this->format_html($strmessage),$this->getheader($video_user)); but the emails are showing like below, عزيزي عضو كليبسر الÙيديو الذي قمت بتØÙ…يله قد ØÙذ٠بواسطة المدير Title : wewewew وجد المدير ÙÙŠ هذا الÙيديو بأنه غير لائق (ملاءم) تØÙŠØ§Øª can anyone help me to solve this problem?......Its very urgent.... Link to comment https://forums.phpfreaks.com/topic/75615-arabic-email-encoding-problem/ Share on other sites More sharing options...
Wuhtzu Posted November 1, 2007 Share Posted November 1, 2007 Hey I think your problem is that UTF-8 is a multibyte encoding which mean 1 character can consist of more than 1 byte. This causes trouble because all "normal" functions treat 1 byte as 1 character. If you for example do substr('ABCDE',0,3) you will expect to get ABC because they are the first 3 characters and the first 3 bytes. But some languages like Arabic, Russian, Chinese and Japanese you need more characters and switch from singlebyte enconding to multibyteencoding. Imagine that a character now consists of an uppercase letter and a lowercase letter: Aa = 1 character. Now things start to go wrong: substr('AaBbCcDdEe',0,3) will return AaB which is 1.5 character and that screws up your encoding everything. So to solve your problem I recommend you start out by switching from mail() to mb_send_mail() which has the same syntax but supports multibyte encoding: http://dk2.php.net/manual/en/function.mb-send-mail.php Here the multibyte functions section on PHP.net: http://dk2.php.net/manual/en/ref.mbstring.php To see problem in "real life" have a look at this: http://wuhtzu.dk/test/mb_string_test_utf-8.php. I wrote it a few days ago when I was wondering about multibyte encoding my self. It shows a string and various functions (both multibyte and singlebyte functions) used on it. Hope this helps Wuhtzu Link to comment https://forums.phpfreaks.com/topic/75615-arabic-email-encoding-problem/#findComment-382601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.