php-在Thunderbird中使用Content-ID和cid嵌入电子邮件图像
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-在Thunderbird中使用Content-ID和cid嵌入电子邮件图像,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2218字,纯文字阅读大概需要4分钟。
内容图文
![php-在Thunderbird中使用Content-ID和cid嵌入电子邮件图像](/upload/InfoBanner/zyjiaocheng/692/b4301ab5b84a4b0cba9d205e006c82b5.jpg)
我在将多个文件附加到HTML电子邮件的PHP应用程序中生成电子邮件.其中一些文件是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中提到.
解决方法:
我注意到两个问题:
> MIME边界不一致.对于第一个附件,它是d0f4ad49cc20d19bf96d4adf9322d567,然后使用b19e863e2cf66b40db1d138b7009010c.因此,技术上第二附件是第一附件的“部分”.
如果将所有b19e863e2cf66b40db1d138b7009010c替换为d0f4ad49cc20d19bf96d4adf9322d567,Thunderbird会正确识别图像附件.
>使用分段/相关而不是分段/混合. (请参阅RFC2387)
A multipart/related is used to indicate that each message part is a component of an aggregate whole. It is for compound objects consisting of several inter-related components – proper display cannot be achieved by individually displaying the constituent parts. The message consists of a root part (by default, the first) which reference other parts inline, which may in turn reference other parts. Message parts are commonly referenced by the “Content-ID” part header. (see 07001)
内容总结
以上是互联网集市为您收集整理的php-在Thunderbird中使用Content-ID和cid嵌入电子邮件图像全部内容,希望文章能够帮你解决php-在Thunderbird中使用Content-ID和cid嵌入电子邮件图像所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。