Jump to content

Arabic Email Encoding Problem


rajeeshvr_80

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.