Shu*_*bbi 3 php email encoding hotmail
我使用以下代码向我的网站成员发送电子邮件.该脚本有效,用户即收到电子邮件.但是,在通过电子邮件发送到Hotmail或Notes时,我确实遇到了编码问题.
代码:
$to = "to@email.com";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset="utf-8"; format="flowed"' . "\r\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\r\n";
$headers .= "To: John Doe<john@doe.com>" . "\r\n" .
"From: John Smith<john@smith.com" . "\r\n" .
"Reply-To: john@doe.com" . "\r\n" .
"Return-Path: john@doe.com" . "\r\n" .
"Sender: john@doe.com" . "\r\n" .
"X-Sender: john@doe.com" . "\r\n" .
"X-Mailer: JohnDoe". "\r\n".
"X-Report-Abuse: Please report abuse to: john@doe.com";
//If the e-mail was successfully sent...
$subject = $translation[104];
if(mail($to, $subject, $message, $headers)){
}
Run Code Online (Sandbox Code Playgroud)
消息和主题都包含瑞典字母Å,Ä和Ö.实际邮件在Hotmail中正确编码和查看,而主题则不是.您可以查看下面的图像以获取更多信息:
图片:http://www.aspkoll.se/imgo/649
我很迷惑.我用谷歌搜索了几天并尝试了不同类型的解决方案,但我没有成功,我担心.
你能帮帮我解决这个问题吗?
不胜感激!
电子邮件主题和其他标题内容(如名称)使用RFC 2047进行编码
php.net评论mail()
给出以下示例:
mail($mail, "=?utf-8?B?".base64_encode ($subject)."?=", $message, $headers);
Run Code Online (Sandbox Code Playgroud)