MIME (RFCs 2045 to 2049) gives a message body a type, an encoding and, for multipart types, a structure of nested parts. Each part has its own header (MIME fields only) and body, separated by an empty line, just like a whole message. This page follows RFC 2045, RFC 2046, RFC 2183, RFC 2231 and the other RFCs named below, all read 2026-11-12.
MIME fields
| Field | Meaning |
|---|---|
MIME-Version | 1.0, in the message header. |
Content-Type | type/subtype and parameters. Without it, text/plain; charset=us-ascii. |
Content-Transfer-Encoding | See encodings; default 7bit. |
Content-ID | <id@domain>; RFC 2392 lets another part refer to it as the URL cid:id@domain. |
Content-Description | Text. |
Content-Disposition | RFC 2183: inline or attachment, with parameters filename, creation-date, modification-date, read-date and size. |
Content-Language, Content-Location | RFC 3282 and RFC 2557. |
Parameters are ; name=value, the value quoted when it has special
characters. RFC 2231 adds character sets and long values:
filename*=UTF-8''na%C3%AFve.txt, and continuations
name*0=, name*1=…
Media types
Top-level types: text (parameter charset; also
format=flowed from RFC 3676), image, audio,
video, application (such as
application/octet-stream and application/pdf),
message and multipart from RFC 2046, model
from RFC 2077 and font from RFC 8081. message/rfc822 is a
whole message inside a part; message/delivery-status is a delivery
status notification (RFC 3464).
| Multipart subtype | Meaning |
|---|---|
mixed | Parts in order, such as a text and attachments. |
alternative | The same content in several forms, in increasing order of preference: the plainest first, the richest last. A reader should show the last one it can. |
related | RFC 2387: a root part and the parts it refers to. |
digest | Parts are messages by default. |
parallel | Parts to be shown together. |
signed | RFC 1847: the content, then its signature; the protocol parameter names the signature type. |
encrypted | RFC 1847: control information, then the encrypted data. |
report | RFC 6522: delivery and read reports. |
Reports: delivery status and disposition notifications
From RFC 6522 (multipart/report), RFC 3464 (delivery status notifications, DSN) and
RFC 8098 (message disposition notifications, MDN), read 2026-11-13.
multipart/report has the syntax of multipart/mixed, a required
boundary and a required report-type parameter whose value is the MIME subtype of the second part.
It has two or three parts: (1) required, a human-readable explanation (any registered type, charset or language, or
multipart/alternative for several); (2) required, the machine-readable report (for example
message/delivery-status); (3) optional, the returned message or a portion of it. A DSN is a
multipart/report with report-type=delivery-status; it must be addressed, in header and envelope, to the
envelope return address of the original message, and an SMTP transaction that sends one uses MAIL FROM:<>
so that no report is issued in response.
message/delivery-status (RFC 3464)
No parameters; 7bit encoding. The body is header-style fields (the usual continuation lines and comments apply; names are case-insensitive): one block of per-message fields, then, each preceded by a blank line, one or more blocks of per-recipient fields. A DSN describes exactly one message, possibly several recipients.
Several fields are type; value pairs: the type is an atom saying how to read the value, and is case-insensitive. The
kinds are address-type (rfc822 for Internet addresses; unknown if it cannot be determined),
diagnostic-type (smtp for an SMTP reply) and MTA-name-type (dns for a host's domain
name). IANA keeps a registry of them, and names that start with X- are not registered. Values of date fields use the
RFC 822 date-time form with a numeric zone (+hhmm).
| Field | Where, times | Syntax and meaning |
|---|---|---|
Original-Envelope-Id | per message, 0 or 1 | *text, case-sensitive: the envelope identifier of the submission transaction (not the Message-ID). Supplied only if the envelope that arrived at the reporting MTA had one, except when the sender's own MTA issues the DSN |
Reporting-MTA | per message, required | mta-name-type ; mta-name: the MTA that attempted the delivery, relay or gatewaying (not necessarily the one that issued the DSN: a gateway that translates a foreign report keeps the name of the original reporting MTA). Case-sensitive; if the MTA has several names, the one used by the environment it accepted the message from |
DSN-Gateway | per message, 0 or 1 | mta-name-type ; mta-name: the gateway that translated a foreign report; must be present exactly when the DSN was translated |
Received-From-MTA | per message, 0 or 1 | mta-name-type ; mta-name: the MTA the message came from; for SMTP the name from HELO/EHLO with the client's address in a comment, type dns |
Arrival-Date | per message, 0 or 1 | date-time the message reached the reporting MTA |
Original-Recipient | per recipient, 0 or 1 | address-type ; generic-address: the recipient as the sender gave it; only when the envelope carried it (SMTP DSN extension) |
Final-Recipient | per recipient, required | address-type ; generic-address: the recipient address as the reporting MTA accepted it, exactly as received (case preserved) unless it has characters not allowed in a DSN field |
Action | per recipient, required | failed (abandoned, no further notice), delayed (still trying, more notices may follow), delivered (terminal; includes delivery to a list exploder, does not mean read), relayed (passed into an environment that does not report delivery; use only if the sender asked for success notices), expanded (delivered and forwarded to several more addresses, not terminal; for an alias, not a list). Any case |
Status | per recipient, required | DIGIT "." 1*3DIGIT "." 1*3DIGIT, no leading zeros, no white space, a comment may follow: class (2 success, 4 persistent temporary failure, 5 permanent failure), subject, detail. The codes are listed below. Action and status are independent: a 4.x.x status can go with either delayed or failed |
Remote-MTA | per recipient, 0 or 1 | mta-name-type ; mta-name: the MTA that reported status to the reporting MTA ("while talking to"); must be absent if none was involved |
Diagnostic-Code | per recipient, 0 or 1 | diagnostic-type ; *text: the transport's own code (for smtp the reply), with an optional comment. If Remote-MTA is present the code came from it, otherwise from the reporting MTA |
Last-Attempt-Date | per recipient, 0 or 1 | date-time of the last attempt (successful or not); absent if not known |
Final-Log-ID | per recipient, 0 or 1 | *text: the final MTA's log identifier for the message |
Will-Retry-Until | per recipient, 0 or 1 | date-time after which the MTA expects to give up; only in delayed notices |
Extension fields may appear in either block; names not starting with X- must be registered with IANA and published in an
RFC. By convention they start with the foreign environment (X400-...), the transport (SMTP-...) or the
MTA that produced the DSN.
Enhanced status codes (RFC 3463)
A status code is class.subject.detail, each a number of one to three digits without leading zeros, no white space or comment
inside. Class: 2 success (details may report conversions needed), 4 persistent transient failure (the message is valid, a
temporary condition caused delay or abandonment, resending may work), 5 permanent failure (resending the same message will not help). A reader
must report the class even if it does not know the subject, and report the subject's general meaning when it does not know the detail; the code
space is extended only by standards-track documents and published codes are never redefined. Subject: 0 other or undefined,
1 addressing, 2 mailbox, 3 mail system, 4 network and routing, 5 mail delivery protocol, 6 message content or media, 7 security or policy.
The details defined in RFC 3463 itself (the registry kept by IANA has later additions, which this page did not open):
| Code | Meaning |
|---|---|
| X.0.0 | other undefined status (only when just the class is known) |
| X.1.0 to X.1.8 | 1.0 other address status; 1.1 bad destination mailbox address (nothing left of the "@"); 1.2 bad destination system address; 1.3 bad destination mailbox syntax; 1.4 destination address ambiguous; 1.5 destination address valid (for positive reports); 1.6 mailbox has moved, no forwarding address; 1.7 bad sender's mailbox syntax; 1.8 bad sender's system address |
| X.2.0 to X.2.4 | 2.0 other mailbox status; 2.1 mailbox disabled; 2.2 mailbox full (transient); 2.3 message length exceeds the per-mailbox limit (permanent); 2.4 mailing list expansion problem |
| X.3.0 to X.3.5 | 3.0 other mail system status; 3.1 mail system full (transient); 3.2 system not accepting network messages; 3.3 system not capable of selected features; 3.4 message too big for system (permanent); 3.5 system incorrectly configured |
| X.4.0 to X.4.7 | 4.0 other network or routing status; 4.1 no answer from host; 4.2 bad connection; 4.3 directory server failure; 4.4 unable to route; 4.5 mail system congestion; 4.6 routing loop detected; 4.7 delivery time expired |
| X.5.0 to X.5.5 | 5.0 other protocol status; 5.1 invalid command; 5.2 syntax error; 5.3 too many recipients; 5.4 invalid command arguments; 5.5 wrong protocol version |
| X.6.0 to X.6.5 | 6.0 other media error; 6.1 media not supported; 6.2 conversion required and prohibited; 6.3 conversion required but not supported; 6.4 conversion with loss performed; 6.5 conversion failed |
| X.7.0 to X.7.7 | 7.0 other security status; 7.1 delivery not authorised, message refused; 7.2 mailing list expansion prohibited; 7.3 security conversion required but not possible; 7.4 security features not supported; 7.5 cryptographic failure; 7.6 cryptographic algorithm not supported; 7.7 message integrity failure |
message/disposition-notification (RFC 8098)
A user agent (not an MTA) reports what became of a message after delivery, as a multipart/report with
report-type=disposition-notification. The same field conventions as a DSN apply (continuation lines, comments in parentheses, case-insensitive names),
but RFC 8098 says the syntax of the Error field includes no comments, so an encoded-word cannot carry
non-ASCII text there (it points to message/global-disposition-notification of RFC 6533 for that). A recipient's
user agent is always free to silently ignore a request for an MDN.
Requesting. In the original message, Disposition-Notification-To: mailbox-list (at most once) asks for
MDNs; Original-Recipient: address-type ; generic-address carries the original recipient; and
Disposition-Notification-Options: attribute = importance , value *(, value) *(; ...) (at most once; importance
is required or optional) carries extension parameters. No attribute is defined in the RFC itself; names
are registered with IANA.
Fields of the notification. In this recommended order (extension fields may appear anywhere):
| Field | Times | Meaning |
|---|---|---|
Reporting-UA | 0 or 1 | ua-name [ ; ua-product ]: the user agent that produced the MDN; a name before the first semicolon, then product identifiers. ua-name may not contain a semicolon |
MDN-Gateway | 0 or 1 | mta-name-type ; mta-name: the gateway that translated a foreign report |
Original-Recipient | 0 or 1 | address-type ; generic-address, copied from the message's Original-Recipient header field; present if there was one or the information is reliably known, otherwise absent |
Final-Recipient | required | address-type ; generic-address: the recipient the MDN is for, usually the MDN's From; it may be an alias instead of a private address |
Original-Message-ID | present if and only if the original had a Message-ID | msg-id |
Disposition | required | action-mode / sending-mode ; type [ / modifier *(, modifier) ]; any case |
Error | any, after Disposition | text explaining the error modifier |
Disposition. Action mode: manual-action (a result of an explicit user instruction; the default) or
automatic-action (for example Sieve reject, fax gateways, voice mail, delivery to a list); exactly one. Sending mode:
MDN-sent-manually (the user gave permission for this MDN; the default) or MDN-sent-automatically (the
agent was set up to send them); exactly one. Types: displayed (shown to someone reading the mailbox; no guarantee it was read),
dispatched (sent somewhere, such as printed, faxed or forwarded, without necessarily being shown),
processed (handled by rules or a server without being shown), deleted (deleted, possibly unread).
Modifier: error, or an extension atom registered with IANA; an unknown modifier must not cause an error message to be sent
to the MDN's sender. A user agent may issue only one MDN per recipient (a forwarding recipient may additionally send a
dispatched one).
text/plain and application/octet-stream
From RFC 2046 section 4.5.1 and
the defaults of RFC 2046 section 4.1.2 (default character set US-ASCII; with no
Content-Type at all the default is text/plain; charset=us-ascii).
Parameter of application/octet-stream | Meaning |
|---|---|
TYPE | The general type or category of the binary data; for the human recipient, not for automatic processing. |
PADDING | The number of bits of padding appended to a bit stream to make whole 8-bit bytes, for a stream whose length is not a multiple of 8 bits. |
Both are optional. CONVERSIONS (RFC 1341) was removed, and NAME
(a suggested file name) was deprecated in favour of Content-Disposition. The
recommended action is to offer to save the data as a file with the transfer encoding
undone; the RFC strongly recommends not implementing a path search that runs a program
named in a parameter such as interpreter=.
message/partial
A fragment of a larger entity, for transports that limit message size
(RFC 2046 section 5.2.2). Its
Content-Transfer-Encoding must be 7bit (the default);
8bit and binary are prohibited, and so the inner message must
not use them either.
| Parameter | Meaning |
|---|---|
id | Unique identifier matching the fragments together, as close to world-unique as possible; in effect a message-id (in double quotes it may be any message-id). |
number | Integer fragment number; numbering begins at 1, not 0. |
total | Integer count of fragments. Required on the final fragment; optional, though encouraged, on earlier ones. |
The parameters may be in any order. Reassembly gives a complete MIME entity with its
own Content-Type; its meaning is that of the inner message, not of a
message containing it. Pieces of a reassembled message may themselves turn out to be
partial messages, which is explicitly allowed. The rules for splitting and joining
(section 5.2.2.1):
- Fragmentation agents split at line boundaries only.
- All header fields of the first enclosing message, except those starting with
Content-and the fieldsSubject,Message-ID,EncryptedandMIME-Version, are copied in order to the new message. - The inner message's fields starting with
Content-, plusSubject,Message-ID,EncryptedandMIME-Version, are appended in order. Its other fields are dropped. - All header fields of the second and later enclosing messages are discarded.
message/external-body
The body data are referenced, not included
(RFC 2046 section 5.2.3). The
entity is a header, a blank line, then the encapsulated message's header; the
encapsulated body itself is external, so what follows the second blank line is a
“phantom body”, ignored except for mail-server. The
encapsulated header must include a Content-ID (also for caching and to
recognise a mail-server reply). The tokens that describe the data, such as file names
and server commands, must be US-ASCII. Content-Transfer-Encoding must be
7bit, as for message/partial.
| Parameter (any access type) | Meaning |
|---|---|
ACCESS-TYPE | Mandatory on every message/external-body; not case-sensitive. Values include FTP, ANON-FTP, TFTP, LOCAL-FILE and MAIL-SERVER; others must be registered with IANA, except experimental X- values. |
EXPIRATION | Optional date (RFC 822 date-time with a 4-digit year) after which the data's existence is not guaranteed. |
SIZE | Optional size in octets of the data in canonical form, before any transfer encoding, to help the recipient decide whether to retrieve it. |
PERMISSION | Optional, case-insensitive: read (the default; the data is retrieved once and not needed again) or read-write (clients may overwrite; any local copy is only a cache). |
| Access type | Parameters |
|---|---|
ftp, tftp | Mandatory NAME (the file name) and SITE (fully qualified domain name). Optional DIRECTORY and MODE: for tftp NETASCII (the default), OCTET, MAIL; for ftp ASCII (the default), EBCDIC, IMAGE, LOCALn (n typically 8), corresponding to FTP types A, E, I and L n. BINARY and TENEX are not valid. The login id and password are never parameters; the user is asked. |
anon-ftp | As ftp, but login is anonymous with the user's mail address as password, with no prompt. |
local-file | Mandatory NAME. Optional SITE: a domain specifier for the machines known to see the file, with * wildcards (*.bellcore.com; a single * for universally available). |
mail-server | Mandatory SERVER (an addr-spec). Optional SUBJECT for the request mail. The full command is the phantom body, which must be included in the request. Access is asynchronous; the reply must carry the same Content-ID. |
Security (section 5.2.3.6): resolving a reference performs an action chosen by the
sender, so a user agent must describe it and ask permission first; a mail-server
request should say that it was generated automatically (for example in a
Comments field); and message integrity guarantees may not cover the
externally retrieved data.
Content-MD5
RFC 1864: an optional integrity
check, generated only by an originating user agent (relays and gateways must not add
it), and only on leaf entities (any type except multipart and
message/rfc822). The MD5 digest is computed over the canonical form of the
data (before the transfer encoding is applied; text with CR LF line ends), and its 16
bytes are written in base64, for example
Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ==. Because trailing white space changes
the digest, quoted-printable or base64 should be the transfer encoding. It may also
appear in the encapsulated header of a message/external-body, to verify the retrieved
data.
Multipart bodies
- The
boundaryparameter is 1 to 70 characters that do not occur in the parts. - Each part starts after a line
--boundary; the last part ends with a line--boundary--. - The CR LF before a boundary line belongs to the boundary, not to the part.
- Text before the first boundary (the preamble) and after the last (the epilogue) is ignored. RFC 2046 notes that many programs put a note for readers without MIME support in the preamble.
Content-Type: multipart/alternative; boundary="b1"
--b1
Content-Type: text/plain; charset=UTF-8
Hello
--b1
Content-Type: text/html; charset=UTF-8
<p>Hello</p>
--b1--
Transfer encodings
| Value | Meaning |
|---|---|
7bit | ASCII lines of at most 998 characters; no encoding. |
8bit | Lines that may hold bytes over 127; needs a mail path that allows it. |
binary | Any bytes, no line rules. |
quoted-printable | Mostly readable text: a byte is written =XX in upper-case hex when it is not printable ASCII or is =; lines at most 76 characters, with = at the end of a line as a soft break; white space at the end of a line must be encoded. |
base64 | Groups of 3 bytes as 4 characters from A–Z a–z 0–9 + /, padded with =; lines at most 76 characters. |
Multipart entities and message/rfc822 bodies may only use
7bit, 8bit or binary; their parts carry their
own encodings.