Microsoft Exchange不会将由PHPmailer生成的电子邮件呈现为HTML [英] Microsoft Exchange doesn't render email generated by PHPmailer as HTML

查看:151
本文介绍了Microsoft Exchange不会将由PHPmailer生成的电子邮件呈现为HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经让我烦恼了几个星期。我有一个脚本,它可以在PHPmailer的帮助下将带有xls附件的html电子邮件发送给多个收件人。它一直工作正常超过一年。最近,来自同一家公司的两名收件人以Microsoft Exchange作为他们的电子邮件客户端,以文本形式接收此电子邮件。以下是他们收到的示例电子邮件:

This issue has been annoyed me for weeks. I have a script which sends html email with xls attachmentm to multiple recipients with the help of PHPmailer. It has been working fine for more than one year. Recently two recipients from the same company, who use Microsoft Exchange as their email client, receive this email as text. Following is sample email they receive:

--b1_dbc2cccc876da210fd56ae7a2601e692
Content-Type: multipart/alternative;
        boundary="b2_dbc2cccc876da210fd56ae7a2601e692"

--b2_dbc2cccc876da210fd56ae7a2601e692
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

To view the message, please use an HTML compatible email viewer!


--b2_dbc2cccc876da210fd56ae7a2601e692
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

....................................
the email body html code in this block
....................................


--b2_dbc2cccc876da210fd56ae7a2601e692--

--b1_dbc2cccc876da210fd56ae7a2601e692
Content-Type: application/octet-stream; name="3MShop-NewOrders_07-30AM-05052014.xls"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="3MShop-NewOrders_07-30AM-05052014.xls"

PGgyPjNNU2hvcC1OZXdPcmRlcnMgMDUtMDUtMjAxNCAwNzozMDoxMCBBTSA8L2gyPjxociAvPjx0
YWJsZSBib3JkZXI9MSBjZWxscGFkZGluZz01IGNlbGxzcGFjaW5nPTI+PHRyPjx0ZCBhbGln

MDUgLSBOYXZ5IEJsdWU8L3RkPjx0ZCBhbGlnbj1sZWZ0PjE8L3RkPjwvdHI+PC90YWJsZT4=

....................................
the rest codes of this attachment
....................................

--b1_dbc2cccc876da210fd56ae7a2601e692--

以下是来自其他收件人的电子邮件标头样本

Following is sample email header from what other recipients get

Content-Type: multipart/mixed;
    boundary="b1_dbc2cccc876da210fd56ae7a2601e692"
Sender:  <emocean@cp60.ezyreg.com>
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - cp60.ezyreg.com
X-AntiAbuse: Original Domain - emoceanstudios.com.au
X-AntiAbuse: Originator/Caller UID/GID - [616 500] / [47 12]
X-AntiAbuse: Sender Address Domain - emoceanstudios.com.au
X-Get-Message-Sender-Via: cp60.ezyreg.com: authenticated_id: emocean/from_h
X-Source: 
X-Source-Args: /usr/sbin/proxyexec -q -d -s /var/run/proxyexec/cagefs.sock/socket /bin/cagefs.server 
X-Source-Dir: emoceanstudios.com.au:/public_html/3M-Shop-Scripts

--b1_dbc2cccc876da210fd56ae7a2601e692
Content-Type: multipart/alternative;
    boundary="b2_dbc2cccc876da210fd56ae7a2601e692"

--b2_dbc2cccc876da210fd56ae7a2601e692
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

To view the message, please use an HTML compatible email viewer!


--b2_dbc2cccc876da210fd56ae7a2601e692
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

不同的是有问题的一个没有部分

As you can easily see the difference is the problematic one has no section of

Content-Type: multipart/mixed;

更奇怪的是,他们的Microsoft Exchange无法将此电子邮件从PHPmailer作为HTML发送,if我将我的Gmail中的同一封电子邮件转发给他们的Exchange,他们现在可以正确呈现它。这让我觉得它可能是我的PHP脚本问题。脚本在这里:

What is more strange is while their Microsoft Exchange can not render this email sent from PHPmailer as HTML, if I forward the same email from my gmail to their Exchange, they can now render it correctly. That makes me think it could possibly be my php script problem. Script is here:

$mail = new PHPMailer(true);
$mail->CharSet = 'UTF-8';


$mail->AddAddress('example@example.com.au', 'example name');
$mail->SetFrom('example@example.com.au', 'example name');

$mail->ContentType = 'text/html';
$mail->IsHTML(true);  

$mail->Subject = 'example subject';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; 

$mail->MsgHTML(file_get_contents('contents.html'));
$mail->AddAttachment($newOrdersReport);      // attachment

$mail->Send();


推荐答案

我不是电子邮件专家,对于我来说:

I'm not an email expert but this doesn't look right to me:

--b1_dbc2cccc876da210fd56ae7a2601e692
Content-Type: multipart/alternative;
boundary="b2_dbc2cccc876da210fd56ae7a2601e692"

您已将Content-Type声明为多部分并定义边界,为什么会重复?

You already declared the Content-Type as multipart and defined the boundary, why is it repeated?

这篇关于Microsoft Exchange不会将由PHPmailer生成的电子邮件呈现为HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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