简体   繁体   中英

PHP - mail() encoding for gmail

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: After a while, I realised that it is only 2 characters, that it represents wrong and that is Ř and ž. All other are alright.

保留格式为UTF-8,我不明白为什么要从utf 8转换为语言特定的编码:/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM