我正在尝试生成其中插入图像的电子邮件文本。我知道我应该使用语法<img src="cid:image-id" />
并将图像添加为附件。我试图这样做,结果如下:
--===============6239034322813840804==
Content-Type: multipart/alternative;
boundary="===============6051774682785554910=="
MIME-Version: 1.0
--===============6051774682785554910==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
my email in base64 with text only
--===============6051774682785554910==
Content-Type: text/html; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
my email in base64 with html
...
<img src="cid:my-image.png" alt="My Image">
...
--===============6051774682785554910==--
--===============6239034322813840804==
MIME-Version: 1.0
Content-Type: image/png; name="badge-img.png"
Content-Disposition: inline; filename="badge-img.png"
Content-ID: <badge-img.png>
Content-Transfer-Encoding: base64
iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI
...
发送时,图片在附件中(可以打开,有效图片)。但在显示的电子邮件内容中,我只看到替代文本“我的图像”,而不是图像。
知道为什么吗?