Jump to content

sending utf-8 email


Logical1

Recommended Posts

Hello

I am trying to generate a confirmation email in which the fonts are not in english.

I use the code bellow.  Problem is that some times the receiver receive the correct fonts & texts and some times giberish.  It must depend on the email software used or setting, etc.

Can anyone suggest a fool-proof way to ake sure the reciever will get te correct text?

Here is the code I am using:

 

 

$to = $Email1;

$subject = "123abc123.com - درخواست  ";

$from_email= "FROM: 123abc123.com";

$from_name= "[email protected]";

$body = $UN." اسم کارائی:";

 

$headers  = "MIME-Version: 1.0 \n" ;

$headers .= "From: " .

      "".mb_encode_mimeheader (mb_convert_encoding($from_name,"UTF-8","AUTO")) ."" .

      "<".$from_email."> \n";

$headers .= "Reply-To: " .

      "".mb_encode_mimeheader (mb_convert_encoding($from_name,"UTF-8","AUTO")) ."" .

      "<".$from_email."> \n";

   

$headers .= "Content-Type: text/plain;charset= UTF-8\n";

$body = mb_convert_encoding($body, "UTF-8","AUTO");

$sendmail_params  = "-f$from_email";

mb_language("uni");

$subject = mb_convert_encoding($subject, "UTF-8","AUTO");

$subject = mb_encode_mimeheader($subject);

mail($to, $subject, $body, $headers, $sendmail_params);

Link to comment
https://forums.phpfreaks.com/topic/159338-sending-utf-8-email/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.