25

Mail multipart/alternative vs multipart/mixedへの回答は、添付ファイルがmultipart/alternativeメッセージのピアであるべきであることを示唆しています。

  • マルチパート/混合
    • マルチパート/代替
      • テキスト/プレーン
      • テキスト/html
    • some/thing (気質: 愛着)
    • some/thing (気質: 愛着)
    • ...

いくつかのインライン画像とプレーンテキストの代替を含む html パーツを含む電子メールを送信したいと思います。さまざまな部分に適した MIME レイアウトは何ですか? コード例やその他の質問にいくつかのオプションが表示されますが、実際に最も効果的だったのはどれですか? 私の傾向はこれです:

  • マルチパート/代替
    • テキスト/プレーン
    • マルチパート/関連
      • text/html (cid による画像の参照)
      • 画像/gif
      • 画像/gif
      • ...

そうすれば、画像は明らかに html 部分をレンダリングするためのものです。この完全な例は次のようになります。

From: Rich Example <rich-example@example.org>
To: A Recipient <recipient@example.org>
Subject: An example of email with images and a plain alternative
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="outer-boundary"

This is a MIME-encoded message. If you are seeing this, your mail
reader is old.
--outer-boundary
Content-Type: text/plain; charset=us-ascii

This message might make you :) or it might make you :(

--outer-boundary
MIME-Version: 1.0
Content-Type: multipart/related;
  type="text/html"; start="<body@here>"; boundary="inner-boundary"

--inner-boundary
Content-Type: text/html; charset=us-ascii
Content-Disposition: inline
Content-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-boundary
Content-Type: image/gif
Content-Disposition: inline
Content-Transfer-Encoding: base64
Content-ID: <smile@here>

R0lGODlhEAAQAKEBAAAAAP//AP//AP//ACH5BAEKAAIALAAAAAAQABAAAAIzlA2px6IBw2
IpWglOvTahDgGdI0ZlGW5meKlci6JrasrqkypxJr8S0oNpgqkGLtcY6hoFADs=

--inner-boundary
Content-Type: image/gif
Content-Disposition: inline
Content-Transfer-Encoding: base64
Content-ID: <frown@here>

R0lGODlhEAAQAKEBAAAAAAD//wD//wD//yH5BAEKAAIALAAAAAAQABAAAAIzlA2px6IBw2
IpWglOvTahDgGdI0ZlGW5meKlci75drDzm5uLZyZ1I3Mv8ZB5Krtgg1RoFADs=

--inner-boundary--

--outer-boundary--
4

1 に答える 1