我有一个设置,我使用 mailx 发送带有附件的电子邮件,并且运行正常。我试图发送一封正文中包含图像的电子邮件。有没有办法做到这一点 - 我尝试了在 google/stackoverflow 上找到的几种方法,但没有显示图像。
答案1
您必须生成类似于以下原始邮件的多部分正文。这就是 gmail 编写此类消息的方式。我没有现成的脚本给您。
Content-Type 行是邮件头的一部分,其余部分是邮件正文。
Content-Type: multipart/related; boundary="00000000000065025f05f70a8645"
--00000000000065025f05f70a8645
Content-Type: multipart/alternative; boundary="00000000000065025c05f70a8644"
--00000000000065025c05f70a8644
Content-Type: text/plain; charset="UTF-8"
before
[image: favicon.png]
after
--
signature
--00000000000065025c05f70a8644
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>before</div><div><img src=3D"cid:ii_lfbkwr450" alt=3D=
"favicon.png" width=3D"64" height=3D"64"><br></div><div>after<br></div><div=
><br></div><div><div><div dir=3D"ltr">-- <br>signature</div></div></div></d=
iv>
--00000000000065025c05f70a8644--
--00000000000065025f05f70a8645
Content-Type: image/png; name="favicon.png"
Content-Disposition: inline; filename="favicon.png"
Content-Transfer-Encoding: base64
Content-ID: <ii_lfbkwr450>
X-Attachment-Id: ii_lfbkwr450
iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAAAXNSR0IArs4c6QAAAARnQU1BAACx
[...some data removed...]
biBkAAAAAElFTkSuQmCC
--00000000000065025f05f70a8645--