[1] [CODE[[CODE(MIME)[message/[VAR[*]]]]]] [[媒体型]]は、
各種プロトコルにおける[[メッセージ]]のための媒体型です。

* 仕様書

[REFS[
- [8] [CITE@en[RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types]] ([TIME[2015-03-22 13:14:46 +09:00]] 版) <http://tools.ietf.org/html/rfc2046#section-3>
- [14] '''[CITE@en[RFC 2046 - Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types]] ([TIME[2015-03-22 13:14:46 +09:00]] 版) <http://tools.ietf.org/html/rfc2046#section-5.2>'''
- [9] [CITE@en[RFC 6532 - Internationalized Email Headers]] ([TIME[2015-02-11 04:16:16 +09:00]] 版) <http://tools.ietf.org/html/rfc6532#section-3.5>
- [10] [CITE@en[RFC 6838 - Media Type Specifications and Registration Procedures]] ([TIME[2015-02-11 00:35:08 +09:00]] 版) <http://tools.ietf.org/html/rfc6838#section-4.2.6>
]REFS]

* [CODE(MIME)@en[message/*]] MIME 型の一覧

[FIG(list)[
[2]
,[CODE(MIME)[[[message/coffeepot]]]]	,[[HTCPCP]] メッセージ	,未登録	,[[RFC 2324]]
,[CODE(MIME)@en[[[message/cpim]]]]	,[[CPIM]] メッセージ	,"[[IETF]] [[提案標準]], [[IANAREG]] 登録済"	,"[[RFC 3862]], [IANAREG]"
,[CODE(MIME)[[[message/delivery-status]]]]	,配送状態報告	([[DSN]])	,	,"[[RFC 1894]], [IANAREG]"
,[CODE(MIME)[[[message/disposition-notification]]]]	,受信者動作報告 ([[MDN]])	,	,"[[RFC 2298]], [IANAREG]"
,[CODE(MIME)@en[[[message/example]]]]	,	,"[[IETF]] [[RFC]], [[IANAREG]] 登録済"	,"[[RFC]], [IANAREG]"
,[CODE(MIME)[[[message/external-body]]]]	,外部実体の参照	,	,"[MIME], [IANAREG]"
,[CODE(MIME)[[[message/x-gnu-rmail]]]]	,[[GNU]] [[rmail]] message
,[CODE(MIME)[[[message/http]]]]	,[[HTTP]] メッセージ	,	,"[HTTP RFC], [IANAREG]"
,[CODE(MIME)[[[message/x-netnews]]]]	,Usenet ニュース・メッセージ	,時代遅れ ->[CODE(MIME)[[[application/news-transmission]]]]
,[CODE(MIME)[[[message/news]]]]	,Usenet ニュース・メッセージ	,時代遅れ->[CODE(MIME)[application/news-transmission]]	,"[[son-of-RFC 1036]],  [IANAREG]"
,[CODE(MIME)[[[message/partial]]]]	,分割メッセージ	,	,"[MIME], [IANAREG]"
,[CODE(MIME)[[[message/rfc822]]]]	,[[RFC 822]] メッセージ	,	,"[MIME], [IANAREG]"
,[CODE(MIME)[[[message/rfc822-headers]]]]	,[[RFC 822]] [[メッセージ]][[頭部]]	,非標準 →[CODE(MIME)[[[text/rfc822-headers]]]]	,
,[CODE(MIME)[[[message/s-http]]]]	,[[S-HTTP]] メッセージ	,	,"[[RFC 2660]], [IANAREG]"
,[CODE(MIME)[[[message/sip]]]]	,[[SIP]] メッセージ	,	,"[[RFC 3261]], [IANAREG]"
,[CODE(MIME)[[[message/sipfrag]]]]	,[[SIP]] メッセージ断片	,	,"[[RFC 3420]], [IANAREG]"
,[CODE(MIME)@en[[[message/teapot]]]]
,[CODE(MIME)@en[[[message/tracking-status]]]]	,	,"[[IETF]] [[提案標準]], [[IANAREG]] 登録済"	,"[[RFC 3886]], [IANAREG]"
]FIG]

- [3] [[IANAREG]]
<http://www.iana.org/assignments/media-types/message/>
[Q@en[Page updated 10-Oct-2004]] ← 嘘。2006年6月6日付け。 

* 意味

[13] [CODE(MIME)@en[[[message/*]]]] は、カプセル化された[[メッセージ]]を表します。
[[本体]]は、何らかの[[メッセージ]]の一部または全部です。 [SRC[>>8]]

* 構文

[5] [CODE(MIME)@en[[[message/*]]]] 全体に共通した構文は特に定められていません。多くは [[RFC 822]]
に由来する似たような構造を持っていますが、それが [CODE(MIME)@en[[[message/*]]]] に属する条件とはなっていません。
似たように見えても実際には処理器を共通化し難い程度に違っています。また、 [[XML]]
ベースのものなど、全く異なる構文のものも登録されています。

[11] [CODE(MIME)@en[[[message/*]]]] [[MIME型]]は、 [[RFC 2046]], >>9 の構文その他の要件に適合しなければ[['''なりません''']] [SRC[>>10]]。

* 分類

[12] [CODE(MIME)@en[[[message/*]]]] は、[[composite type]] です [SRC[>>10]]。

* CTE

[15] [[MIME型]]によっては、[[CTE]] に制限があります [SRC[>>14]]。

[19] [[電子メール]]を想定した新しい [CODE(MIME)@en[[[message/*]]]] [[MIME型]]は、
[CODE(MIME)@en[[[7bit]]]] に制限するべきです。制限できなければ
[CODE(MIME)@en[[[message/*]]]] 以外を使うべきです。 [SRC[>>14]]

[6] [CODE(MIME)@en[[[message/*]]]] は、 [CODE(MIME)@en[[[7bit]]]]、[CODE(MIME)@en[[[8bit]]]]、
[CODE(MIME)@en[[[binary]]]] 以外の [[CTE]] の使用が禁じられています。 [[HTTP]]
など任意のバイト列を転送できる近代的なプロトコルでは問題ありませんが、 [[SMTP]] など [[MIME]]
が当初想定していた古いプロトコルでは仕様に沿った形で利用できないデータもあり得ます。

[4]
[CODE(MIME)@en[[[message/[VAR[*]]]]]] を含む[[合成型]]における非[[同一]]の[[内容転送符号化]]
([[Base64]] など) の使用は禁止されてきましたが ([[RFC 2045]] 6.4)、
[[RFC 5335]] によって制限が緩和され、 [CODE(MIME)@en[[[message/[VAR[*]]]]]]
に属する[[亜型]]は個別に[[内容転送符号化]]の使用を認められるように変更されました
([[RFC 5335]] 4.1)。第1号として、 [CODE(MIME)@en[[[message/global]]]]
で[[内容転送符号化]]の使用が認められています。

* 処理

[16] [[関門]]その他[[電子メール]]の処理器は、 [[RFC 822]] [[メッセージ]]の[[ヘッダー]]を変更することがあります。
しかし [CODE(MIME)@en[[[message/*]]]] で埋め込まれた[[メッセージ]]の[[ヘッダー]]を変更してはなりません。 [SRC[>>14]]

[18] 認識できない [CODE(MIME)@en[[[message/*]]]] のデータは、
[CODE(MIME)@en[[[application/octet-stream]]]] のように扱わなければなりません [SRC[>>14]]。

* 歴史

[FIG(quote)[
[FIGCAPTION[
[17] RFC 2046 (MIME インターネット媒体型) 5.2.  Message Media Type
]FIGCAPTION]

> It is frequently desirable, in sending mail, to encapsulate another
mail message.  A special media type, "message", is defined to
facilitate this.  In particular, the "rfc822" subtype of "message" is
used to encapsulate RFC 822 messages.

メイルを送る際に、他のメイル・メッセージをカプセル化するのが望ましい
ことがしばしばあります。
この目的のために特別な媒体型 [CODE(MIME)[message]] を定義します。
特に、 [CODE(MIME)[message]] の [CODE(MIME)[rfc822]] 亜型は
RFC 822 メッセージのカプセル化のために使います。

> NOTE:  It has been suggested that subtypes of "message" might be
defined for forwarded or rejected messages.  However, forwarded and
rejected messages can be handled as multipart messages in which the
first part contains any control or descriptive information, and a
second part, of type "message/rfc822", is the forwarded or rejected
message.  Composing rejection and forwarding messages in this manner
will preserve the type information on the original message and allow
it to be correctly presented to the recipient, and hence is strongly 
encouraged.

参考: [CODE(MIEM)[message]] の亜型を転送メッセージや拒絶メッセージ用として定義したらどうかと提案されています。
しかし、転送メッセージや拒絶メッセージは、
最初の[[部分]]に制御情報や説明的情報を含み、
二番目の部分が型 [CODE(MIME)[[[message/rfc822]]]]
で転送メッセージや拒絶メッセージとする[[多部分]]メッセージとして取扱うことができます。
拒絶メッセージや転送メッセージをこの方法で構成すれば元のメッセージの型情報を保存することができますし、
受信者に正しくみせることができますから、
こちらを強く推奨いたします。

[INS[

> [INS[([[RFC 2046]] より)]]
Subtypes of "message" often impose restrictions on what encodings are
allowed.  These restrictions are described in conjunction with each
specific subtype.

[CODE(MIME)[message]] の亜型にはしばしば、
どの符号化が認められるかについての制限を課します。
この制限は各亜型の規定と共に説明します。
]INS]

[DEL[

> [INS[([[RFC 1341]], [[RFC 1521]] より)]]
As stated in the definition of the Content-Transfer-Encoding field,
no encoding other than "7bit", "8bit", or "binary" is permitted for
messages or parts of type "message".  Even stronger restrictions
apply to the subtypes "message/partial" and "message/external-body",
as specified below.  The message header fields are always US-ASCII in
any case, and data within the body can still be encoded, in which
case the Content-Transfer-Encoding header field in the encapsulated
message will reflect this.  Non-ASCII text in the headers of an
encapsulated message can be specified using the mechanisms described
in [RFC-1522].

CTE 領域の定義で述べたように、 〜 以外の符号化はメッセージや型 
"message"の部分には認められていません。より強い制限を、
下に説明するように亜型 "message/partial" および "message/external-body"
には課します。メッセージ頭領域は常にどんな場合も US-ASCII
で、本文中のデータは符号化されていても構いません。その場合はカプセル化
メッセージの Content-Transfer-Encoding 頭領域がこれを反映しています。
カプセル化メッセージの頭中の非 US-ASCII 文は、 RFC 1522 で説明されている
方法を使って記述出来ます。
]DEL]

> Mail gateways, relays, and other mail handling agents are commonly
known to alter the top-level header of an RFC 822 message.  In
particular, they frequently add, remove, or reorder header fields.
These operations are explicitly forbidden for the encapsulated
headers embedded in the bodies of messages of type "message."

メイル関門・中継者・その他メイルを取り扱う代理者は、
RFC 822 メッセージの最上位の頭をいじることが良く知られています。
特に、よく頭領域を追加したり削除したり並べ替えたりします。
こうした操作は、型 "message" のメッセージの本文に埋め込まれている
カプセル化されたかしらに対しては、ここに明示的に禁止します。

* 5.2.1.  RFC822 Subtype

See [[message/rfc822]]

* 5.2.2.  Partial Subtype

See [[message/partial]]

* 5.2.3.  External-Body Subtype

See [[message/external-body]]

* 5.2.4.  Other Message Subtypes 他の Message 亜型

> MIME implementations must in general treat unrecognized subtypes of
"message" as being equivalent to "application/octet-stream".

MIME 実装は通常、認識出来ない "message" の亜型を、
"application/octet-stream" と同等であるものとして扱わなければなりません。

> Future subtypes of "message" intended for use with email should be
restricted to "7bit" encoding. A type other than "message" should be
used if restriction to "7bit" is not possible.

将来の電子メイルでの使用を意図した "message" の亜型は、
"7bit" 符号化に制限されるべきです。 "7bit" に制限することが可能では
無い場合は、"message" 以外の型を使用するべきです。

[INS[

> [INS[(RFC 1521 より)]]
The formal grammar for content-type header fields for data of type
message is given by:

型 message のデータの content-type 頭領域の正式な文法は次の通りです。

>
[PRE[
   message-type := "message" "/" message-subtype
>
   message-subtype := "rfc822"
                   / "partial" 2#3partial-param
                   / "external-body" 1*external-param
                   / extension-token
]PRE]

[INS[

編集者注:
[CODE(ABNF)[2''#''3partial-param]] は [CODE(ABNF)[2''*''3]] 
の誤りでしょう。 [CODE(ABNF)[#]] だったらえらいこっちゃ。
]INS]

>
[PRE[
   partial-param :=     (";" "id" "=" value)
              /  (";" "number" "=" 1*DIGIT)
              /  (";" "total" "=" 1*DIGIT)
         ; id & number required; total  required  for  last part
           [INS[id と number は必須。 total は最後の部分には必須]]
>
   external-param :=   (";" "access-type" "=" atype)
              / (";" "expiration" "=" date-time)
                   ; Note that date-time is quoted
              / (";" "size" "=" 1*DIGIT)
              / (";"  "permission"  "="  ("read"  /  "read-write"))
                   ; Permission is case-insensitive
                     [INS[permission は大文字・小文字を区別しない]]
              / (";" "name" "="  value)
              / (";" "site" "=" value)
              / (";" "dir" "=" value)
              / (";" "mode" "=" value)
              / (";" "server" "=" value)
              / (";" "subject" "=" value)
          ; access-type required;others required based on access-type
            [INS[access-type は必須。他は access-type によっては必要]]
>
   atype := "ftp" / "anon-ftp" / "tftp" / "local-file"
                  / "afs" / "mail-server" / extension-token
                  ; Case-insensitive
                    [INS[大文字・小文字を区別しない]]
]PRE]
]INS]
]FIG]

* メモ

[7] [[MIME]] において使える 
[ABBR[[[CTE]]] [[CODE(MIME)[[[Content-Transfer-Encoding]]]] ]]
に著しい制限が加えられている
([[MIME'r]] の判断ミスだったんじゃないかな。今から考えれば。)
ため、多くの媒体型は
[CODE(MIME)[[[application/[VAR[*]]]]]] にも対応するものがあります。