【发布时间】:2015-06-29 00:48:39
【问题描述】:
我在 PHP 应用程序中生成电子邮件,该应用程序将多个文件附加到 HTML 电子邮件。一些文件是 Excel 电子表格,一些文件是需要嵌入 HTML 中的公司徽标,因此它们默认使用 Content-ID 和 cid 标识符加载以引用附加的图像。
据我所知,我的语法是正确的,但图像永远不会内联加载(但是它们已成功附加)。
From: email@example.com
Reply-To: email@example.com
MIME-Version: 1.0
Content-type: multipart/mixed;boundary="d0f4ad49cc20d19bf96d4adf9322d567"
Message-Id: <20150421165500.0A5488021B@server>
Date: Tue, 21 Apr 2015 12:54:59 -0400 (EDT)
--d0f4ad49cc20d19bf96d4adf9322d567
Content-type: text/html; charset=utf-8
Content-transfer-encoding: 8bit
<html>
Html message goes here, followed by email.<br/>
<img src="cid:mylogo" />
</html>
--d0f4ad49cc20d19bf96d4adf9322d567
Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name=excelsheet.xlsx
Content-Description: excelsheet.xlsx
Content-Disposition: attachment;
filename="excelsheet.xlsx"; size=24712;
Content-transfer-encoding:base64
[base64 encoded string goes here.]
--b19e863e2cf66b40db1d138b7009010c
Content-Type: image/jpeg;
name="mylogo.jpg"
Content-transfer-encoding:base64
Content-ID: <mylogo>
Content-Disposition: inline;
filename="mylogo.jpg"; size=7579;
[base64 encoded string goes here.]
--b19e863e2cf66b40db1d138b7009010c--
任何人都可以看到图像无法按预期嵌入的明显原因吗?
编辑
请注意,这种行为并非适用于所有电子邮件客户端。到目前为止,仅在 Thunderbird 中记录。
【问题讨论】:
-
这实际上似乎特定于 Linux 上的 Mozilla Thunderbird(到目前为止)。电子邮件通过 GMail 正确显示并嵌入图像,并且似乎通过 Windows 上的 Thunderbird。
-
更正 - 在 Windows 上的 Thunderbird 上也不起作用
-
Thunderbird 默认不禁用嵌入图像吗?
-
正如@undefined 所说,Thunderbird 会自动阻止图像,您是否检查过这是否导致了您的问题?
-
这可能不会导致您的问题,但知道这是一件好事:Content-ID 值应该有一个
@登录。它们基本上是 URL 编码的电子邮件地址。见RFC2392。
标签: php email html-email email-attachments thunderbird