PHP - Gmail 的 mail() 编码
我有一个从 PHP 发送邮件的函数,我想发送捷克语字母,例如 ř,ě,š,č,ř,ž,ý,á,é ..
该函数如下所示:
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
编码有效对于我尝试过的所有邮件客户端,除了谷歌的 gmail。
有什么想法,我可以如何改进它,以便 gmail 也可以使用吗?
谢谢,迈克。
编辑:过了一会儿,我意识到它只有 2 个字符,它代表错误,那就是 Ř 和 ž。其他都还好。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将格式保留为 UTF-8 ,我不明白为什么要从 utf 8 转换为特定于语言的编码:/
Leave the formating as UTF-8 , i don't understand why would you convert from utf 8 to language specific encoding :/