5. Composite Media Type Values (複合メディアタイプ値)
2つの複合トップレベルメディアタイプは: multipartとmessageです。
5.1. Multipart Media Type (マルチパートメディアタイプ)
multipartタイプは、複数のbody partを単一のメッセージに組み合わせるために使用されます。各partは、独自のヘッダーと本文を持つ独立したエンティティです。
5.1.1. 共通構文
すべてのmultipartタイプは共通の構文を共有します。boundaryパラメータは必須です (REQUIRED):
Content-Type: multipart/mixed; boundary="----=_Part_0_123456789.987654321"
------=_Part_0_123456789.987654321
Content-Type: text/plain
最初のpart内容
------=_Part_0_123456789.987654321
Content-Type: text/html
<html>2番目のpart内容</html>
------=_Part_0_123456789.987654321--
5.1.3. Mixedサブタイプ
multipart/mixedは、順番に提示する必要がある独立したpartに使用されます。
使用例: メール本文 + 添付ファイル
Content-Type: multipart/mixed; boundary="boundary123"
--boundary123
Content-Type: text/plain
メール本文
--boundary123
Content-Type: application/pdf
Content-Disposition: attachment; filename="document.pdf"
[PDFデータ]
--boundary123--
5.1.4. Alternativeサブタイプ
multipart/alternativeは、同じ内容の異なる表現に使用されます。メールクライアントは、理解できる最後のバージョンを選択すべきです (SHOULD)。
使用例: プレーンテキスト + HTMLバージョン
Content-Type: multipart/alternative; boundary="alt123"
--alt123
Content-Type: text/plain
プレーンテキストバージョン
--alt123
Content-Type: text/html
<html><body>HTMLバージョン</body></html>
--alt123--
5.1.5. Digestサブタイプ
multipart/digestは、複数のメッセージを転送するために使用されます。デフォルトのpartタイプはmessage/rfc822です。
5.1.6. Parallelサブタイプ
multipart/parallelは、partを同時に提示すべきであることを示します。
5.1.7. その他のMultipartサブタイプ
multipart/related: 関連part (例: HTML + 埋め込み画像)multipart/form-data: HTMLフォームファイルアップロードmultipart/byteranges: HTTP範囲リクエスト
5.2. Message Media Type (メッセージメディアタイプ)
messageタイプは、別のメッセージをカプセル化するために使用されます。
5.2.1. RFC822サブタイプ
message/rfc822は、完全なRFC 822メッセージをカプセル化するために使用されます。
Content-Type: message/rfc822
From: [email protected]
To: [email protected]
Subject: 転送されたメッセージ
これは転送されたメッセージの内容です。
5.2.2. Partialサブタイプ
message/partialは、大きなメッセージを複数のフラグメントに分割するために使用されます。
パラメータ:
id: 一意の識別子number: フラグメント番号total: 総フラグメント数
Content-Type: message/partial;
id="[email protected]";
number=1;
total=3
5.2.3. External-Bodyサブタイプ
message/external-bodyは、他の場所に格納されているデータを参照するために使用されます。
アクセスタイプ:
ftp: FTPサーバーhttp: HTTP URLlocal-file: ローカルファイルmail-server: メールサーバー
Content-Type: message/external-body;
access-type=URL;
URL="http://example.com/file.pdf"
Content-Type: application/pdf
Content-Description: 大きなPDFファイル
典型的な多層ネスト構造:
multipart/mixed
├── text/plain (本文)
├── multipart/alternative
│ ├── text/plain
│ └── text/html
└── application/pdf (添付ファイル)