生成的 HTML 邮件在 Thunderbird 中未正确显示(在 Evolution 或 roundcube webmail 中看起来正常)
我正在使用 PHP 发送 HTML 邮件,它被 Evolution 端 Roundcube 网络邮件完美接收,但是当我在 Mozilla Thunderbird 中查看它时,我看到的只是纯文本形式的 html。
这是邮件的开头:
Return-Path: <[email protected]>
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on KIP-DU-VPS
X-Spam-Level:
X-Spam-Status: No, score=-100.8 required=5.0 tests=BAYES_00,HTML_MESSAGE,
HTML_MIME_NO_HTML_TAG,MIME_HTML_ONLY,NO_RELAYS,USER_IN_WHITELIST autolearn=no
version=3.3.1
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: by me.be (Postfix, from userid 33)
id 232B627273; Mon, 30 May 2011 14:41:39 +0200 (CEST)
To: [email protected]; [email protected]
Subject: [Content] Uw aanvraag werd goedgekeurd
From: FromName <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="398a5f7c07527a0a59c4d87e6547f2d5"
Message-Id: <[email protected]>
Date: Mon, 30 May 2011 14:41:39 +0200 (CEST)
--398a5f7c07527a0a59c4d87e6547f2d5
Content-Type: text/html; charset="utf8"
Content-Transfer-Encoding: 7bit
<br/><head>
<style type="text/css">
snip inside html
</body>
--398a5f7c07527a0a59c4d87e6547f2d5
Content-Type: application/octet-stream; name="onkosten.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="onkosten.pdf"
JVBERi0xLjQNCjEgMCBvYmoNCjw8DQovQ3JlYXRvciA8RkVGRjAwNEIwMDZEMDAyRDAwNzYwMDY1
MDA3MjAwNjcwMDZFMDA2MTAwNzMwMDYzMDA2ODAwNkYwMDZDMDA2OTAwNkUwMDY3MDAyRTAwNzgw
snip inside attachment
OTI0IDAwMDAwIG4NCjAwMDAwMDI3MTIgMDAwMDAgbg0KMDAwMDAyMTgxOCAwMDAwMCBuDQowMDAw
MDIzMjA3IDAwMDAwIG4NCjAwMDAwMjQ2MTEgMDAwMDAgbg0KdHJhaWxlcg0KPDwNCi9TaXplIDE1
DQovSW5mbyAxIDAgUg0KL1Jvb3QgMiAwIFINCi9JRFs8ZjU2Y2E5ZmFlNjY5MmQzZmNhOGQyOTIz
ZjUxNzFmYTY+PGY1NmNhOWZhZTY2OTJkM2ZjYThkMjkyM2Y1MTcxZmE2Pl0KPj4NCnN0YXJ0eHJl
Zg0KMjUwMzINCiUlRU9GDQo=
--398a5f7c07527a0a59c4d87e6547f2d5--
Thunderbird 将“From”行之后的所有内容呈现为纯文本正文。 (从“MIME-Version: 1.0”开始)
邮件有问题吗?
这是发送带有附件的邮件的函数:
function mailAttachmentHeader($attachment, $message ) { $mime_boundary = md5(time()); $xMessage = "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"\r\n\r\n"; $xMessage .= "--".$mime_boundary."\r\n"; //$xMessage .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $xMessage .= "Content-Type: text/html; charset=\"utf8\"\r\n"; $xMessage .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $xMessage .= $message."\r\n\r\n"; foreach($attachment as $file) { $xMessage .= "--".$mime_boundary."\r\n"; $xMessage .= "Content-Type: application/octet-stream; name=\"".basename($file)."\"\r\n"; $xMessage .= "Content-Transfer-Encoding: base64\r\n"; $xMessage .= "Content-Disposition: attachment; filename=\"".basename($file)."\"\r\n\r\n"; $content = file_get_contents($file); $xMessage.= chunk_split(base64_encode($content)); $xMessage .= "\r\n\r\n"; } $xMessage .= "--".$mime_boundary."--\r\n\r\n"; return $xMessage; }
I'm sending an HTML mail with PHP, it's being received perfectly by Evolution end Roundcube webmail, but when I look at it in Mozilla Thunderbird all I see is the html as plain text.
Here's the beginning of the mail:
Return-Path: <[email protected]>
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on KIP-DU-VPS
X-Spam-Level:
X-Spam-Status: No, score=-100.8 required=5.0 tests=BAYES_00,HTML_MESSAGE,
HTML_MIME_NO_HTML_TAG,MIME_HTML_ONLY,NO_RELAYS,USER_IN_WHITELIST autolearn=no
version=3.3.1
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: by me.be (Postfix, from userid 33)
id 232B627273; Mon, 30 May 2011 14:41:39 +0200 (CEST)
To: [email protected]; [email protected]
Subject: [Content] Uw aanvraag werd goedgekeurd
From: FromName <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="398a5f7c07527a0a59c4d87e6547f2d5"
Message-Id: <[email protected]>
Date: Mon, 30 May 2011 14:41:39 +0200 (CEST)
--398a5f7c07527a0a59c4d87e6547f2d5
Content-Type: text/html; charset="utf8"
Content-Transfer-Encoding: 7bit
<br/><head>
<style type="text/css">
snip inside html
</body>
--398a5f7c07527a0a59c4d87e6547f2d5
Content-Type: application/octet-stream; name="onkosten.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="onkosten.pdf"
JVBERi0xLjQNCjEgMCBvYmoNCjw8DQovQ3JlYXRvciA8RkVGRjAwNEIwMDZEMDAyRDAwNzYwMDY1
MDA3MjAwNjcwMDZFMDA2MTAwNzMwMDYzMDA2ODAwNkYwMDZDMDA2OTAwNkUwMDY3MDAyRTAwNzgw
snip inside attachment
OTI0IDAwMDAwIG4NCjAwMDAwMDI3MTIgMDAwMDAgbg0KMDAwMDAyMTgxOCAwMDAwMCBuDQowMDAw
MDIzMjA3IDAwMDAwIG4NCjAwMDAwMjQ2MTEgMDAwMDAgbg0KdHJhaWxlcg0KPDwNCi9TaXplIDE1
DQovSW5mbyAxIDAgUg0KL1Jvb3QgMiAwIFINCi9JRFs8ZjU2Y2E5ZmFlNjY5MmQzZmNhOGQyOTIz
ZjUxNzFmYTY+PGY1NmNhOWZhZTY2OTJkM2ZjYThkMjkyM2Y1MTcxZmE2Pl0KPj4NCnN0YXJ0eHJl
Zg0KMjUwMzINCiUlRU9GDQo=
--398a5f7c07527a0a59c4d87e6547f2d5--
Thunderbird renders everything after the "From" line as plaintext body.
(Starting from "MIME-Version: 1.0")
Is there something wrong with the mail?
Here's the function for sending the mail with attachments:
function mailAttachmentHeader($attachment, $message ) { $mime_boundary = md5(time()); $xMessage = "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"\r\n\r\n"; $xMessage .= "--".$mime_boundary."\r\n"; //$xMessage .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $xMessage .= "Content-Type: text/html; charset=\"utf8\"\r\n"; $xMessage .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $xMessage .= $message."\r\n\r\n"; foreach($attachment as $file) { $xMessage .= "--".$mime_boundary."\r\n"; $xMessage .= "Content-Type: application/octet-stream; name=\"".basename($file)."\"\r\n"; $xMessage .= "Content-Transfer-Encoding: base64\r\n"; $xMessage .= "Content-Disposition: attachment; filename=\"".basename($file)."\"\r\n\r\n"; $content = file_get_contents($file); $xMessage.= chunk_split(base64_encode($content)); $xMessage .= "\r\n\r\n"; } $xMessage .= "--".$mime_boundary."--\r\n\r\n"; return $xMessage; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论