本文介绍了MIME类型以满足HTML,电子邮件,图像和纯文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Mail multipart / alternative vs multipart / mixed 的答案表明附件应该是 multipart / alternative 消息,如:The answer to Mail multipart/alternative vs multipart/mixed suggests that attachments should be peers of the multipart/alternative message, like: multipart / mixed multipart / alternative text / plain text / html 我想发送电子邮件与html部分与一些内联图像和纯文本替代。什么是各个部分的首选MIME布局?几个选项出现在示例代码和其他问题中,但在实践中最有效?我的意思是:I'd like to send email with an html part with some inline images and a plain text alternative. What is the preferred MIME layout for the various parts? A couple of options appear in example code and in other questions, but which have worked best in practice? My inclination is this: multipart / alternative text / multipart / related text / html(通过cid引用图片) image / gif image / gif ... multipart/alternativetext/plainmultipart/relatedtext/html (referencing the images by cid)image/gifimage/gif...这样,图像显然是为了呈现html部分的目的。一个完整的例子是:That way, the images are clearly for the purpose of rendering the html part. A full example of this would be:From: Rich Example <[email protected]>To: A Recipient <[email protected]>Subject: An example of email with images and a plain alternativeMIME-Version: 1.0Content-Type: multipart/alternative; boundary="outer-boundary"This is a MIME-encoded message. If you are seeing this, your mailreader is old.--outer-boundaryContent-Type: text/plain; charset=us-asciiThis message might make you :) or it might make you :(--outer-boundaryMIME-Version: 1.0Content-Type: multipart/related; type="text/html"; start="<body@here>"; boundary="inner-boundary"--inner-boundaryContent-Type: text/html; charset=us-asciiContent-Disposition: inlineContent-ID: <body@here><html> <body> This message might make you <img src="cid:smile@here" alt="smile"> or it might make you <img src="cid:frown@here" alt="frown"> </body></html>--inner-boundaryContent-Type: image/gifContent-Disposition: inlineContent-Transfer-Encoding: base64Content-ID: <smile@here>R0lGODlhEAAQAKEBAAAAAP//AP//AP//ACH5BAEKAAIALAAAAAAQABAAAAIzlA2px6IBw2IpWglOvTahDgGdI0ZlGW5meKlci6JrasrqkypxJr8S0oNpgqkGLtcY6hoFADs=--inner-boundaryContent-Type: image/gifContent-Disposition: inlineContent-Transfer-Encoding: base64Content-ID: <frown@here>R0lGODlhEAAQAKEBAAAAAAD//wD//wD//yH5BAEKAAIALAAAAAAQABAAAAIzlA2px6IBw2IpWglOvTahDgGdI0ZlGW5meKlci75drDzm5uLZyZ1I3Mv8ZB5Krtgg1RoFADs=--inner-boundary----outer-boundary-- 推荐答案你是对的内联图像应存储在 multipart / related mime-entity(RFC 2387)中,并提供多种内容类型选项可以使用 multipart / alternative (RFC 2046)。 要添加附件,您可以将整个结构放入 multipart / mixed 中并添加附件You are right. Inline images should be stored in a multipart/related mime-entity (RFC 2387) and offering multiple content-type options can be done with multipart/alternative (RFC 2046).For adding attachments you may put the whole structure into a multipart/mixed and add the attachments. multipart / mixed multipart / alternative text / plain multipart / related text / html image / gif image / gif multipart/mixedmultipart/alternativetext/plainmultipart/relatedtext/htmlimage/gifimage/gif您还可以在文本/简单消息中使用内联图像,但并不是所有MUA都支持此功能。 (不使用或处置:inline)You can also use inline image in text/plain messages, but not all MUA support this. (Use none or disposition: inline) multipart / mixed text / plain (文字上图) image / gif text / plain(文字下图) 我不知道一个干净的方式将其与多部分/替代HTML电子邮件相结合。And I dont't know a clean way to combine this with a multipart/alternative HTML-email. 这篇关于MIME类型以满足HTML,电子邮件,图像和纯文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-23 21:12