Mic*_*son 7 php email encoding utf-8
我搜索并搜索了解决方案,但无济于事.
我正在使用php邮件发送一个混合的文本/ HTML电子邮件,以utf8编码.这是相关的代码:
$headers = "From: $fromPerson\r\n" .
"Content-Transfer-Encoding: 8bit\r\n".
"Reply-To: $fromPerson\r\n" .
"Content-Type: multipart/alternative; boundary=". $mime_boundary_header. "\r\n" .
"X-Mailer: PHP/" . phpversion();
$message = "$notice_text
--$mime_boundary
Content-Type: text/plain; charset='UTF-8'
Content-Transfer-Encoding: 8bit
$textEmail
--$mime_boundary
Content-Type: text/html; charset='UTF-8'
Content-Transfer-Encoding: 8bit
$htmlEmail
--$mime_boundary--";
//mb_detect_encoding($message) returns UTF-8
$mail_sent = @mail( $to, $subject, $message, $headers);
Run Code Online (Sandbox Code Playgroud)
这些消息包含西班牙语以及那些棘手的字符.这些电子邮件在gmail,hotmail(在线Outlook),mac邮件,电话等方面都很好用,但在Windows Live邮件或Microsoft Outlook中却没有.
如果我手动将Windows Live Mail中的默认字体设置为utf8,则消息会正确显示,但不会显示.如果我将来自其他客户端的电子邮件转发到Outlook或windows live,它也会显示正常.
我可以找到工作我敢肯定,但我错过了什么吗?我不想依赖接收器知道如何更改消息的编码,所以我需要添加到电子邮件中以提示这些客户端识别编码吗?
如果这已经在其他地方处理过,我道歉,我会感激任何建议.看起来我应该继续使用PHPMailer来查看是否能解决问题,但出于个人好奇心,了解为什么会发生这种情况会很有趣......
Arn*_*anc 13
我不确定'包裹charset是必要的,甚至是正确的.尝试删除它们:
Content-Type: text/plain; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: example@example.com\r\n";
$headers .= "Reply-To: example@example.com\r\n";
Run Code Online (Sandbox Code Playgroud)