具有utf-8编码的php邮件在Microsoft邮件客户端中显示不正确 [英] php mail with utf-8 encoding displays incorrectly in Microsoft mail clients

查看:81
本文介绍了具有utf-8编码的php邮件在Microsoft邮件客户端中显示不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索并搜索了一个解决方案,但无济于事。

I've searched and searched for a solution to this but to no avail.

我正在使用php邮件发送一个混合的文本/ html电子邮件,在utf8编码。以下是相关代码:

I'm using the php mailer to send out a mixed text / html email, encoded in utf8. Here's the relevant code:

$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);

消息包含西班牙语以及这些棘手的字符。电子邮件在gmail,hotmail(在线展望),mac邮件,手机等中显示正常,但Windows Live邮件或Microsoft Outlook中没有显示。

The messages contain Spanish along with those tricky characters. The emails display fine in gmail, hotmail (online outlook), mac mail, phones etc. but not in Windows live mail or Microsoft outlook.

如果我手动设置默认Windows中的字体实时邮件到utf8消息正确显示,但否则不会。如果我将电子邮件从另一个客户端转发到Outlook或Windows Live,它也会显示正常。

If I manually set the default font in Windows live Mail to utf8 the message displays correctly, but otherwise it does not. If I forward the email from another client to outlook or windows live it displays fine as well.

我可以找到工作,我敢肯定,但我错过了什么?我不想依靠接收者知道如何更改消息的编码,所以有什么需要添加到电子邮件中提示这些客户端识别编码?

I could find work arounds I'm sure, but am I missing something? I don't want to rely on the receivers knowing how to change the encoding of the message, so is there something I need to add to the email to prompt these clients to recognise the encoding?

如果这已经在其他地方处理,我很抱歉,我会感谢任何建议。看起来我应该继续使用PHPMailer来查看是否解决了这个问题,但出于个人的好奇心,这将是有趣的,了解为什么会发生这种情况...

I apologise if this has been dealt with elsewhere, and I'll appreciate any advice. It looks like I should just go ahead and use PHPMailer to see if that fixes the problem, but out of personal curiosity it would be interesting to learn why this is happening...

推荐答案

我不知道包装字符集的'是必要的,甚至是正确的。尝试删除它们:

I'm not sure that the ' wrapping the charset are necessary, or even correct. Try removing them:

Content-Type: text/plain; charset=UTF-8

这篇关于具有utf-8编码的php邮件在Microsoft邮件客户端中显示不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆