如您所知,作为电子邮件传递的所有内容都必须文本化。
- 您必须创建包含多部分/ mime消息的电子邮件。
- 如果要添加物理图像,则该图像必须使用base 64编码并分配了Content-ID(cid)。如果是URL,则
<img />
标记就足够了(图像的url必须链接到Source ID)。
典型的电子邮件示例如下所示:
From: foo1atbar.netTo: foo2atbar.netSubject: A simple exampleMime-Version: 1.0Content-Type: multipart/related; boundary="boundary-example"; type="text/html"--boundary-exampleContent-Type: text/html; charset="US-ASCII"... text of the HTML document, which might contain a URIreferencing a resource in another body part, for examplethrough a statement such as:<IMG SRC="cid:foo4atfoo1atbar.net" ALT="IETF logo">--boundary-exampleContent-Location: CID:somethingatelse ; this header is disregardedContent-ID: <foo4atfoo1atbar.net>Content-Type: IMAGE/GIFContent-Transfer-Encoding: base64R0lGODlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNvcHlyaWdodCAoQykgMTk5LiBVbmF1dGhvcml6ZWQgZHVwbGljYXRpb24gcHJvaGliaXRlZC4A etc...--boundary-example--
正如你所看到的,
Content-ID:<foo4atfoo1atbar.net>ID匹配到
<IMG>的
SRC="cid:foo4atfoo1atbar.net"。这样,客户端浏览器会将您的图像呈现为内容而不是附件。
希望这可以帮助。



