Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Microsoft Exchange没有';t将PHPmailer生成的电子邮件呈现为HTML_Php_Html_Email_Exchange Server_Phpmailer - Fatal编程技术网

Microsoft Exchange没有';t将PHPmailer生成的电子邮件呈现为HTML

Microsoft Exchange没有';t将PHPmailer生成的电子邮件呈现为HTML,php,html,email,exchange-server,phpmailer,Php,Html,Email,Exchange Server,Phpmailer,这个问题困扰了我好几个星期。我有一个脚本,它可以在PHPmailer的帮助下将带有xls attachmentm的html电子邮件发送给多个收件人。一年多以来,它一直运转良好。最近,来自同一家公司的两名收件人使用Microsoft Exchange作为电子邮件客户端,以文本形式接收此电子邮件。以下是他们收到的电子邮件示例: --b1_dbc2cccc876da210fd56ae7a2601e692 Content-Type: multipart/alternative; boun

这个问题困扰了我好几个星期。我有一个脚本,它可以在PHPmailer的帮助下将带有xls attachmentm的html电子邮件发送给多个收件人。一年多以来,它一直运转良好。最近,来自同一家公司的两名收件人使用Microsoft Exchange作为电子邮件客户端,以文本形式接收此电子邮件。以下是他们收到的电子邮件示例:

--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--
以下是其他收件人收到的电子邮件标题示例

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
更奇怪的是,虽然他们的Microsoft Exchange无法将PHPmailer发送的这封电子邮件呈现为HTML格式,但如果我将同一封电子邮件从gmail转发到他们的Exchange,他们现在可以正确呈现。这让我觉得这可能是我的php脚本问题。脚本如下:

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

请在收到电子邮件时附上电子邮件的源代码。我知道一些旧版本的Exchange,即不带SP1的2007,据报道会以纯文本显示HTML电子邮件。我知道OWA对HTML电子邮件的支持非常差。OWA是唯一一个我从来没能让我的电子邮件看起来很好的客户。这远不是你问题的答案,但也许有一些东西可以激发研究


另一个想法。。当通过PHPmailer和Gmail发送电子邮件时,您应该查看并比较电子邮件附带的安全性。SPK和DKIM提示以及SpamAssassin评分在客户端显示电子邮件的方式中起着重要作用。如果您没有通过PHPmailer对消息进行身份验证,则触发交换很可能会限制消息的显示方式

我不是电子邮件专家,但这在我看来并不合适:

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

您已经将内容类型声明为multipart并定义了边界,为什么要重复它?

请尝试不同的邮件属性/“mail”、“sendmail”或“smtp”/。“mail”是此类中的默认值(表示PHP mail()函数)。IMHO“smtp”最适用于带有附件的邮件<代码>$mail->Mailer='smtp'--b1_dbc2cccc876da210fd56ae7a2601e692 Content-Type: multipart/alternative; boundary="b2_dbc2cccc876da210fd56ae7a2601e692"