开发者

PHP - mail() encoding for gmail

开发者 https://www.devze.com 2023-01-06 13:03 出处:网络
I have a function for sending mail from PHP and I want to be albe to send Czech letters, like ř,ě,š,č,ř,ž,ý,á,é ..

I have a function for sending mail from PHP and I want to be albe to send Czech letters, like ř,ě,š,č,ř,ž,ý,á,é ..

The function goes like this:

function sendMail($to, $from, $subject, $body) {

$headers = "From: $from\r\n";
$headers .= "Content-type: text/html\r\n";

$body = iconv("UTF-8", 'ISO-8859-2', $body);

$content = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-2' /></head><body>";

$content .= $body;

$content .=  "</body></html>";


$success = mail($to, $subject, $content, $headers);

if($success)
    return TRUE;
else
    return FALSE;

} // end: function

And the encoding works for all mail clients I have tryed, except google's gmail.

Any idea, how I could improve it, so the gmail also works?

Thanks, Mike.

EDIT: Aft开发者_JAVA技巧er a while, I realised that it is only 2 characters, that it represents wrong and that is Ř and ž. All other are alright.


Leave the formating as UTF-8 , i don't understand why would you convert from utf 8 to language specific encoding :/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号