I'm using rather specified charset (ISO-8859-2) because not every mail system (for example: http://10minutemail.com) can read UTF-8 mails. If you need this:
function utf8_to_latin2($str)
{
return iconv ( 'utf-8', 'ISO-8859-2' , $str );
}
function my_mail($to,$s,$text,$form, $reply)
{
mail($to,utf8_to_latin2($s),utf8_to_latin2($text),
"From: $form\r\n".
"Reply-To: $reply\r\n".
"X-Mailer: PHP/" . phpversion());
}
I have made another mailer function, because apple device could not read well the previous version.
function utf8mail($to,$s,$body,$from_name="x",$from_a = "info@x.com", $reply="info@x.com")
{
$s= "=?utf-8?b?".base64_encode($s)."?=";
$headers = "MIME-Version: 1.0\r\n";
$headers.= "From: =?utf-8?b?".base64_encode($from_name)."?= <".$from_a.">\r\n";
$headers.= "Content-Type: text/plain;charset=utf-8\r\n";
$headers.= "Reply-To: $reply\r\n";
$headers.= "X-Mailer: PHP/" . phpversion();
mail($to, $s, $body, $headers);
}
mail()
orZend_Mail
orPHPMailer
? Need some code of the Factory method! – Wesley van Opdorp Sep 1 '11 at 6:59$mail = Mail::factory("mail");
$to = "me@abc.com";
$body = "好信";
$headers = array("Content-type =>"text/plain: charset=\"UTF-8","From" => "abc@abc.com","To" => "me@abc.com","Subject" => "Test Send Chinese mail-好信");
$mail->send($to, $headers, $body);
Is this correct? It does not show what I expect. It should display out chinese word in body,header or even subject. – deepWebMie Sep 1 '11 at 8:04