RFC 1521
MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies
MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies ๐
okay bestie, this is RFC 1521 ๐ from the Network Working Group, and it's all about MIME, the thing that lets emails carry pictures, audio, and fancy text. The authors are N. Borenstein (Bellcore) and N. Freed (Innosoft) ๐ซถ. It's dated September 1993 and it's on the Standards Track โจ. It obsoletes RFC 1341 ๐ , so this is the new version of that earlier spec.
Status of this Memo ๐
okay so this RFC specifies an Internet standards track protocol for the whole Internet community, and it's literally asking everyone to chime in with discussion and suggestions for improvements ๐ซถ. For the current standardization state and status of this protocol, check the "Internet Official Protocol Standards" doc ๐. Also, distribution of this memo is unlimited, so share away ๐ .
Abstract ๐ธ
okay this part is the TL;DR and it's giving big energy ๐ฅ. STD 11, RFC 822 defines a message representation protocol that gets super detailed about message headers, but it leaves the message content (aka the message body) as flat ASCII text ๐. This document redefines the format of message bodies so you can represent and exchange multi-part textual and non-textual message bodies without loss of information โจ. It's based on earlier work in RFC 934 and STD 11, RFC 1049, but it extends and revises that work ๐. Because RFC 822 said so little about message bodies, this document is largely orthogonal to (rather than a revision of) RFC 822, so it's more of a side-quest than a glow-up ๐ง.
In particular, this doc is built to let you include multiple objects in a single message ๐ฆ, represent body text in character sets other than US-ASCII ๐, do formatted multi-font text messages ๐ , include non-textual stuff like images and audio fragments ๐ฆ, and generally make it easy for future extensions to define new types of Internet mail for cooperating mail agents ๐.
This document does NOT extend Internet mail header fields to permit anything other than US-ASCII text data ๐ โโ๏ธ. Those extensions are the subject of a companion document, [RFC-1522] ๐.
This document is a revision of RFC 1341 ๐. The significant differences from RFC 1341 are summarized in Appendix H โจ.
Table of Contents ๐๏ธ
1. Introduction....................................... 3
2. Notations, Conventions, and Generic BNF Grammar.... 6
3. The MIME-Version Header Field...................... 7
4. The Content-Type Header Field...................... 9
5. The Content-Transfer-Encoding Header Field......... 13
5.1. Quoted-Printable Content-Transfer-Encoding......... 18
5.2. Base64 Content-Transfer-Encoding................... 21
6. Additional Content-Header Fields................... 23
6.1. Optional Content-ID Header Field................... 23
6.2. Optional Content-Description Header Field.......... 24
7. The Predefined Content-Type Values................. 24
7.1. The Text Content-Type.............................. 24
7.1.1. The charset parameter.............................. 25
7.1.2. The Text/plain subtype............................. 28
7.2. The Multipart Content-Type......................... 28
7.2.1. Multipart: The common syntax...................... 29
7.2.2. The Multipart/mixed (primary) subtype.............. 34
7.2.3. The Multipart/alternative subtype.................. 34
7.2.4. The Multipart/digest subtype....................... 36
7.2.5. The Multipart/parallel subtype..................... 37
7.2.6. Other Multipart subtypes........................... 37
7.3. The Message Content-Type........................... 38
7.3.1. The Message/rfc822 (primary) subtype............... 38
7.3.2. The Message/Partial subtype........................ 39
7.3.3. The Message/External-Body subtype.................. 42
7.3.3.1. The "ftp" and "tftp" access-types............... 44
7.3.3.2. The "anon-ftp" access-type...................... 45
7.3.3.3. The "local-file" and "afs" access-types......... 45
7.3.3.4. The "mail-server" access-type................... 45
7.3.3.5. Examples and Further Explanations............... 46
7.4. The Application Content-Type....................... 49
7.4.1. The Application/Octet-Stream (primary) subtype..... 50
7.4.2. The Application/PostScript subtype................. 50
7.4.3. Other Application subtypes......................... 53
7.5. The Image Content-Type............................. 53
7.6. The Audio Content-Type............................. 54
7.7. The Video Content-Type............................. 54
7.8. Experimental Content-Type Values................... 54
8. Summary............................................ 56
9. Security Considerations............................ 56
10. Authors' Addresses................................. 57
11. Acknowledgements................................... 58
Appendix A -- Minimal MIME-Conformance.................... 60
Appendix B -- General Guidelines For Sending Email Data... 63
Appendix C -- A Complex Multipart Example................. 66
Appendix D -- Collected Grammar........................... 68
Appendix E -- IANA Registration Procedures................ 72
E.1 Registration of New Content-type/subtype Values...... 72
E.2 Registration of New Access-type Values
for Message/external-body............................ 73
Appendix F -- Summary of the Seven Content-types.......... 74
Appendix G -- Canonical Encoding Model.................... 76
Appendix H -- Changes from RFC 1341....................... 78
References................................................ 80
1. Introduction โจ
okay so the big story: since 1982, STD 11, RFC 822 [RFC-822] has defined the standard format of textual mail messages on the Internet ๐. It's been so successful that the RFC 822 format got adopted, fully or partly, way beyond the Internet and the Internet SMTP transport defined by STD 10, RFC 821 [RFC-821] ๐. As more people used it, a bunch of limitations started feeling super restrictive for users ๐ญ.
RFC 822 was meant to specify a format for text messages, so non-text messages (like multimedia stuff with audio or images) just aren't mentioned at all ๐. Even for text, RFC 822 isn't enough for mail users whose languages need character sets richer than US ASCII [US-ASCII] ๐ธ. Since RFC 822 doesn't specify mechanisms for mail with audio, video, Asian language text, or even text in most European languages, we need more specs ๐ง.
One notable limitation of RFC 821/822 mail systems is that they restrict the contents of electronic mail messages to relatively short lines of seven-bit ASCII ๐. That forces users to convert any non-textual data they want to send into seven-bit bytes that can be represented as printable ASCII characters, before invoking a local mail UA (User Agent, a program that human users use to send and receive mail) ๐. Examples of encodings used on the Internet right now include pure hexadecimal, uuencode, the 3-in-4 base 64 scheme specified in RFC 1421, the Andrew Toolkit Representation [ATK], and many others ๐.
The limitations of RFC 822 mail get even more obvious when gateways are built to exchange mail between RFC 822 hosts and X.400 hosts ๐ฅ. X.400 [X400] specifies mechanisms for including non-textual body parts within electronic mail messages ๐ฆ. The current standards for mapping X.400 messages to RFC 822 messages specify either that X.400 non-textual body parts must be converted to (not encoded in) an ASCII format, or that they must be discarded while notifying the RFC 822 user that discarding has occurred ๐ญ. This is clearly undesirable, because information a user may want to receive is lost ๐. Even if a user's UA can't handle the non-textual body part, the user might have some mechanism outside the UA that can extract useful information from it ๐ง . It also doesn't account for the fact that the message may eventually be gatewayed back into an X.400 message handling system (i.e., the X.400 message is "tunneled" through Internet mail), where the non-textual information would definitely become useful again ๐ซถ.
This document describes several mechanisms that combine to solve most of these problems without introducing any serious incompatibilities with the existing world of RFC 822 mail โจ. In particular, it describes:
- A
MIME-Versionheader field, which uses a version number to declare a message conformant with this specification. It lets mail processing agents tell these messages apart from those generated by older or non-conformant software, which is presumed to lack such a field ๐. - A
Content-Typeheader field, generalized from RFC 1049 [RFC-1049], which can specify the type and subtype of data in a message body and fully specify the native representation (encoding) of that data ๐ .- 2.a. A "text" Content-Type value, which can represent textual information in a number of character sets and formatted text description languages in a standardized manner ๐.
- 2.b. A "multipart" Content-Type value, which can combine several body parts, possibly of differing types of data, into a single message ๐งฉ.
- 2.c. An "application" Content-Type value, which can transmit application data or binary data, and so, among other uses, implement an electronic mail file transfer service ๐.
- 2.d. A "message" Content-Type value, for encapsulating another mail message ๐.
- 2.e. An "image" Content-Type value, for transmitting still image (picture) data ๐ธ.
- 2.f. An "audio" Content-Type value, for transmitting audio or voice data ๐ง.
- 2.g. A "video" Content-Type value, for transmitting video or moving image data, possibly with audio as part of the composite video data format ๐ฌ.
- A
Content-Transfer-Encodingheader field, which can specify an auxiliary encoding that was applied to the data so it can pass through mail transport mechanisms that may have data or character set limitations ๐. - Two additional header fields that further describe the data in a message body: the
Content-IDandContent-Descriptionheader fields ๐.
MIME has been carefully designed as an extensible mechanism, and it's expected that the set of content-type/subtype pairs and their associated parameters will grow significantly over time ๐. Several other MIME fields, notably including character set names, are likely to get new values defined over time too ๐ท. To make sure those values get developed in an orderly, well-specified, and public manner, MIME defines a registration process that uses the Internet Assigned Numbers Authority (IANA) as a central registry for such values ๐๏ธ. Appendix E gives the details on how IANA registration works ๐.
Finally, to specify and promote interoperability, Appendix A of this document provides a basic applicability statement for a subset of the above mechanisms. It defines a minimal level of "conformance" with this document ๐.
HISTORICAL NOTE: Okay bestie, a few of these mechanisms are gonna look kinda strange, or even baroque, at first ๐. But the working group had two big priorities: compatibility with existing standards AND robustness across existing practice ๐. Compatibility was always favored over elegance, so no cap, it's not always the prettiest ๐.
MIME was first defined and published as RFCs 1341 and 1342 [RFC-1341] [RFC-1342]. This document is a relatively minor updating of RFC 1341, and it's meant to supersede it โจ. The differences between this document and RFC 1341 are summarized in Appendix H ๐. For the standardization state and status of this protocol, check the current edition of the "IAB Official Protocol Standards" ๐. Several other RFC documents will be of interest to the MIME implementor too, in particular [RFC 1343], [RFC-1344], and [RFC-1345] ๐.
2. Notations, Conventions, and Generic BNF Grammar ๐
This document comes in two versions: plain ASCII text and PostScript (PostScript is a trademark of Adobe Systems Incorporated.) ๐จ๏ธ. The text version is the official specification, but some of you will find the PostScript version way easier to read. The textual contents are identical. There's also an Andrew-format copy of this document available from the first author (Borenstein) ๐.
Okay so, the mechanisms here are all described in prose, but most are also described formally in the modified BNF notation of RFC 822 ๐งฉ. Implementors need to be familiar with this notation to understand the spec, and RFC 822 is where you go for a full explanation of the modified BNF notation ๐.
Some of the modified BNF in this document refers to syntactic entities that are defined in RFC 822 and not in this document. So the complete formal grammar is the combo of this document's collected grammar appendix, plus RFC 822, plus the RFC 1123 modifications to RFC 822, which specifically change the syntax for return', date' and `mailbox' ๐ซถ.
In this document, CRLF means the sequence of the two ASCII characters CR (13) and LF (10). Taken together, in this order, they denote a line break in RFC 822 mail ๐.
The term "character set" here refers to a method used with one or more tables to convert encoded text to a series of octets ๐ค. This definition is broad enough to cover all kinds of text encodings, from simple single-table mappings like ASCII to complex table switching methods like those using ISO 2022's techniques ๐. However, a MIME character set name must fully specify the mapping to be performed โจ.
"Message", when not further qualified, means either the complete (or "top-level") message being transferred on a network, or a message encapsulated in a body of type "message" ๐จ.
A "body part" means one of the parts of the body of a multipart entity. A body part has a header and a body, so it makes sense to talk about the body of a body part ๐ง.
An "entity" means either a message or a body part. All kinds of entities share the property that they have a header and a body ๐ฆ.
"Body", when not further qualified, means the body of an entity, which is the body of either a message or of a body part ๐ .
NOTE: The previous four definitions are clearly circular. This is unavoidable, since the overall structure of a MIME message is indeed recursive. ๐
All numeric and octet values in this document are given in decimal notation ๐ข.
It must be noted that Content-Type values, subtypes, and parameter names as defined in this document are case-insensitive. Parameter values, however, are case-sensitive unless otherwise specified for the specific parameter ๐ .
FORMATTING NOTE: This document has been carefully formatted for ease of reading ๐. The PostScript version, in particular, puts notes like this one, which readers may skip, in a smaller, italicized font, and indents them too. In the text version, only the indentation is preserved, so if you're reading the text version you might consider using the PostScript version instead ๐. However, all such notes will be indented and preceded by "NOTE:" or some similar introduction, even in the text version โจ. The main purpose of these non-essential notes is to share the rationale behind this document, or to place it in its proper historical or evolutionary context ๐ฐ๏ธ. Readers who are entirely focused on building a conformant implementation can skip them, but they're super useful if you want to understand why this document is written the way it is ๐ง . For ease of recognition, all BNF definitions have been placed in a fixed-width font in the PostScript version of this document ๐ป.
3. The MIME-Version Header Field ๐ฆ
Since RFC 822 was published in 1982, there's really been only one format standard for Internet messages ๐ฌ. So there was very little perceived need to declare which format standard was in use. This document is an independent document that complements RFC 822. The extensions here were defined to be compatible with RFC 822, but there are still situations where it might be useful for a mail-processing agent to know whether a message was composed with the new standard in mind ๐.
So this document defines a new header field, "MIME-Version", which declares the version of the Internet message body format standard in use ๐.
Messages composed in accordance with this document MUST include such a header field, with the following verbatim text:
MIME-Version: 1.0
The presence of this header field is an assertion that the message has been composed in compliance with this document ๐ซถ.
Since a future document might extend the message format standard again, there's a formal BNF for the content of the MIME-Version field ๐งฉ:
version := "MIME-Version" ":" 1*DIGIT "." 1*DIGIT
So future format specifiers, which might replace or extend "1.0", are constrained to be two integer fields separated by a period ๐ข. If a message is received with a MIME-version value other than "1.0", it cannot be assumed to conform with this specification ๐ซ.
The MIME-Version header field is required at the top level of a message โจ. It is not required for each body part of a multipart entity ๐ง. It is required for the embedded headers of a body of type "message" if and only if the embedded message is itself claimed to be MIME-conformant ๐.
It's not possible to fully specify how a conformant mail reader should treat a message that arrives in the future with some MIME-Version value other than "1.0" ๐ฎ. Still, conformant software is encouraged to check the version number and at least warn the user if an unrecognized MIME-version shows up ๐จ.
Also worth noting: version control for specific content-types is NOT handled by the MIME-Version mechanism ๐ โโ๏ธ. Some formats, like application/postscript, have version numbering conventions that live inside the document format itself. Where those conventions exist, MIME doesn't supersede them. Where no such conventions exist, a MIME type might use a "version" parameter in the content-type field if necessary ๐ .
NOTE TO IMPLEMENTORS: All header fields defined in this document, including MIME-Version, Content-type, etc., are subject to the general syntactic rules for header fields specified in RFC 822 ๐ง. In particular, all of them can include comments, which means these two MIME-Version fields are equivalent ๐: MIME-Version: 1.0 MIME-Version: 1.0 (Generated by GBD-killer 3.7)
4. The Content-Type Header Field ๐
The whole point of the Content-Type field is to describe the data in the body well enough that the receiving user agent can pick an appropriate agent or mechanism to present it to the user, or otherwise deal with it properly ๐ธ.
HISTORICAL NOTE: The Content-Type header field was first defined in RFC 1049 ๐. RFC 1049 Content-types used a simpler, less powerful syntax, but it's largely compatible with the mechanism given here ๐ซถ.
The Content-Type header field specifies the nature of the data in the body of an entity, by giving type and subtype identifiers and by providing auxiliary information that may be required for certain types ๐. After the type and subtype names, the rest of the header field is just a set of parameters in attribute/value notation โจ. The set of meaningful parameters differs between types. There are NO globally-meaningful parameters that apply to all content-types ๐ โโ๏ธ. Global mechanisms are best handled in the MIME model by defining additional Content-* header fields ๐งฉ. The ordering of parameters is not significant ๐. One of the defined parameters is a "charset" parameter, which declares the character set used in the body ๐ค. Comments are allowed under RFC 822 rules for structured header fields ๐ฌ.
Generally, the top-level Content-Type declares the general type of data, while the subtype specifies a specific format for that type ๐. So a Content-Type of "image/xyz" is enough to tell a user agent that the data is an image, even if it has no idea what the specific image format "xyz" is ๐ผ๏ธ. That info can be used to decide whether or not to show a user the raw data from an unrecognized subtype. That's a reasonable move for unrecognized subtypes of text, but not for unrecognized subtypes of image or audio ๐. For this reason, registered subtypes of audio, image, text, and video should not contain embedded information that is really of a different type ๐ซ. Compound types should be represented using the "multipart" or "application" types instead ๐ง.
Parameters just modify the content-subtype and don't fundamentally affect the requirements of the host system ๐. Most parameters only make sense with certain content-types, but others are "global" in the sense that they might apply to any subtype ๐. For example, the "boundary" parameter only makes sense for the "multipart" content-type, while the "charset" parameter might make sense with several content-types ๐ฆ.
This document defines an initial set of seven Content-Types ๐. This top-level set is meant to be substantially complete. Additions to the larger set of supported types can generally be made by creating new subtypes of these initial types ๐. More top-level types may be defined in the future, but only through an extension to this standard ๐ฎ. If another primary type is used for any reason, it must be given a name starting with "X-" to show its non-standard status and to avoid a potential conflict with a future official name โ ๏ธ.
In the Augmented BNF notation of RFC 822, a Content-Type header field value is defined as follows ๐งฉ:
content := "Content-Type" ":" type "/" subtype *(";"
parameter)
; case-insensitive matching of type and subtype
Okay so this is where the grammar gets super picky ๐โจ Here's the type part of Content-Type, and every bit of it matters:
type := "application" / "audio"
/ "image" / "message"
/ "multipart" / "text"
/ "video" / extension-token
; All values case-insensitive
extension-token := x-token / iana-token
iana-token := <a publicly-defined extension token,
registered with IANA, as specified in
appendix E>
x-token := <The two characters "X-" or "x-" followed, with
no intervening white space, by any token>
subtype := token ; case-insensitive
parameter := attribute "=" value
attribute := token ; case-insensitive
value := token / quoted-string
token := 1*<any (ASCII) CHAR except SPACE, CTLs,
or tspecials>
tspecials := "(" / ")" / "<" / ">" / "@"
/ "," / ";" / ":" / "\" / <">
/ "/" / "[" / "]" / "?" / "="
; Must be in quoted-string,
; to use within parameter values
Note that the definition of "tspecials" is the same as the RFC 822 definition of "specials" with the addition of the three characters "/", "?", and "=", and the removal of ".". ๐
Note also that a subtype specification is MANDATORY. There are no default subtypes. ๐ซถ
The type, subtype, and parameter names are not case sensitive. For example, TEXT, Text, and TeXt are all equivalent. ๐ Parameter values are normally case sensitive, but certain parameters are interpreted to be case-insensitive, depending on the intended use. (For example, multipart boundaries are case-sensitive, but the "access-type" for message/External-body is not case-sensitive.) ๐
Beyond this syntax, the only constraint on the definition of subtype names is the desire that their uses must not conflict. That is, it would be undesirable to have two different communities using Content-Type: application/foobar to mean two different things. ๐ญ The process of defining new content-subtypes, then, is not intended to be a mechanism for imposing restrictions, but simply a mechanism for publicizing the usages. There are, therefore, two acceptable mechanisms for defining new Content-Type subtypes:
- Private values (starting with "X-") may be defined bilaterally between two cooperating agents without outside registration or standardization.
- New standard values must be documented, registered with, and approved by IANA, as described in Appendix E. Where intended for public use, the formats they refer to must also be defined by a published specification, and possibly offered for standardization.
The seven standard initial predefined Content-Types are detailed in the bulk of this document. They are:
- text -- textual information. The primary subtype, "plain", indicates plain (unformatted) text. No special software is required to get the full meaning of the text, aside from support for the indicated character set. Subtypes are to be used for enriched text in forms where application software may enhance the appearance of the text, but such software must not be required in order to get the general idea of the content. Possible subtypes thus include any readable word processor format. A very simple and portable subtype, richtext, was defined in RFC 1341, with a future revision expected. ๐
- multipart -- data consisting of multiple parts of independent data types. Four initial subtypes are defined, including the primary "mixed" subtype, "alternative" for representing the same data in multiple formats, "parallel" for parts intended to be viewed simultaneously, and "digest" for multipart entities in which each part is of type "message". ๐งฉ
- message -- an encapsulated message. A body of Content-Type "message" is itself all or part of a fully formatted RFC 822 conformant message which may contain its own different Content-Type header field. The primary subtype is "rfc822". The "partial" subtype is defined for partial messages, to permit the fragmented transmission of bodies that are thought to be too large to be passed through mail transport facilities. Another subtype, "External-body", is defined for specifying large bodies by reference to an external data source. ๐
- image -- image data. Image requires a display device (such as a graphical display, a printer, or a FAX machine) to view the information. Initial subtypes are defined for two widely-used image formats, jpeg and gif. ๐ผ๏ธ
- audio -- audio data, with initial subtype "basic". Audio requires an audio output device (such as a speaker or a telephone) to "display" the contents. ๐ง
- video -- video data. Video requires the capability to display moving images, typically including specialized hardware and software. The initial subtype is "mpeg". ๐ฌ
- application -- some other kind of data, typically either uninterpreted binary data or information to be processed by a mail-based application. The primary subtype, "octet-stream", is to be used in the case of uninterpreted binary data, in which case the simplest recommended action is to offer to write the information into a file for the user.
An additional subtype, "PostScript", is defined for transporting PostScript documents in bodies. Other expected uses for "application" include spreadsheets, data for mail-based scheduling systems, and languages for "active" (computational) email. (Note that active email and other application data may entail several security considerations, which are discussed later in this memo, particularly in the context of application/PostScript.) ๐ฅ
Default RFC 822 messages are typed by this protocol as plain text in the US-ASCII character set, which can be explicitly specified as "Content-type: text/plain; charset=us-ascii". If no Content-Type is specified, this default is assumed. In the presence of a MIME-Version header field, a receiving User Agent can also assume that plain US-ASCII text was the sender's intent. In the absence of a MIME-Version specification, plain US-ASCII text must still be assumed, but the sender's intent might have been otherwise. ๐ธ
RATIONALE: In the absence of any Content-Type header field or MIME-Version header field, it is impossible to be certain that a message is actually text in the US-ASCII character set, since it might well be a message that, using the conventions that predate this document, includes text in another character set or non-textual data in a manner that cannot be automatically recognized (e.g., a uuencoded compressed UNIX tar file). Although there is no fully acceptable alternative to treating such untyped messages as "text/plain; charset=us-ascii", implementors should remain aware that if a message lacks both the MIME-Version and the Content-Type header fields, it may in practice contain almost anything. ๐
It should be noted that the list of Content-Type values given here may be augmented in time, via the mechanisms described above, and that the set of subtypes is expected to grow substantially. ๐ฑ
When a mail reader encounters mail with an unknown Content-type value, it should generally treat it as equivalent to "application/octet-stream", as described later in this document. ๐ง
5. The Content-Transfer-Encoding Header Field โจ
Many Content-Types which could usefully be transported via email are represented, in their "natural" format, as 8-bit character or binary data. Such data cannot be transmitted over some transport protocols. For example, RFC 821 restricts mail messages to 7-bit US-ASCII data with lines no longer than 1000 characters. ๐
It is necessary, therefore, to define a standard mechanism for re-encoding such data into a 7-bit short-line format. This document specifies that such encodings will be indicated by a new "Content-Transfer-Encoding" header field. The Content-Transfer-Encoding field is used to indicate the type of transformation that has been used in order to represent the body in an acceptable manner for transport. ๐ฆ
Unlike Content-Types, a proliferation of Content-Transfer-Encoding values is undesirable and unnecessary. However, establishing only a single Content-Transfer-Encoding mechanism does not seem possible. There is a tradeoff between the desire for a compact and efficient encoding of largely-binary data and the desire for a readable encoding of data that is mostly, but not entirely, 7-bit data. For this reason, at least two encoding mechanisms are necessary: a "readable" encoding and a "dense" encoding. ๐ค
The Content-Transfer-Encoding field is designed to specify an invertible mapping between the "native" representation of a type of data and a representation that can be readily exchanged using 7 bit mail transport protocols, such as those defined by RFC 821 (SMTP). This field has not been defined by any previous standard. The field's value is a single token specifying the type of encoding, as enumerated below. Formally:
encoding := "Content-Transfer-Encoding" ":" mechanism
mechanism := "7bit" ; case-insensitive
/ "quoted-printable"
/ "base64"
/ "8bit"
/ "binary"
/ x-token
These values are not case sensitive. That is, Base64 and BASE64 and bAsE64 are all equivalent. An encoding type of 7BIT requires that the body is already in a seven-bit mail-ready representation. This is the default value -- that is, "Content-Transfer-Encoding: 7BIT" is assumed if the Content-Transfer-Encoding header field is not present. ๐
The values "8bit", "7bit", and "binary" all mean that NO encoding has been performed. However, they are potentially useful as indications of the kind of data contained in the object, and therefore of the kind of encoding that might need to be performed for transmission in a given transport system. In particular:
- "7bit" means that the data is all represented as short lines of US-ASCII data.
- "8bit" means that the lines are short, but there may be non-ASCII characters (octets with the high-order bit set).
- "Binary" means that not only may non-ASCII characters be present, but also that the lines are not necessarily short enough for SMTP transport.
The difference between "8bit" (or any other conceivable bit-width token) and the "binary" token is that "binary" does not require adherence to any limits on line length or to the SMTP CRLF semantics, while the bit-width tokens do require such adherence. If the body contains data in any bit-width other than 7-bit, the appropriate bit-width Content-Transfer-Encoding token must be used (e.g., "8bit" for unencoded 8 bit wide data). If the body contains binary data, the "binary" Content-Transfer-Encoding token must be used. ๐
NOTE: okay so the difference between the Content-Transfer-Encoding values of "binary", "8bit", etc. ๐ may seem unimportant, bc all of them really mean "none". Like, there has been no encoding of the data for transport ๐ซถ. However, clear labeling will be of enormous value to gateways between future mail transport systems with differing capabilities in transporting data that do not meet the restrictions of RFC 821 transport โจ.
Mail transport for unencoded 8-bit data is defined in RFC-1426 [RFC-1426]. As of the publication of this document, there are no standardized Internet mail transports for which it is legitimate to include unencoded binary data in mail bodies. Thus there are no circumstances in which the "binary" Content-Transfer-Encoding is actually legal on the Internet ๐. However, in the event that binary mail transport becomes a reality in Internet mail, or when this document is used in conjunction with any other binary-capable transport mechanism, binary bodies should be labeled as such using this mechanism ๐ฆ.
NOTE: the five values defined for the Content-Transfer-Encoding field imply nothing about the Content-Type other than the algorithm by which it was encoded or the transport system requirements if unencoded ๐ธ.
Implementors may, if necessary, define new Content-Transfer-Encoding values, but must use an x-token, which is a name prefixed by "X-" to indicate its non-standard status, e.g., "Content-Transfer-Encoding: x-my-new-encoding" ๐. Now here's the tea: unlike Content-Types and subtypes, the creation of new Content-Transfer-Encoding values is explicitly and strongly discouraged ๐
โโ๏ธ, bc it seems likely to hinder interoperability with little potential benefit. Their use is allowed only as the result of an agreement between cooperating user agents ๐ค.
If a Content-Transfer-Encoding header field appears as part of a message header, it applies to the entire body of that message โจ. If a Content-Transfer-Encoding header field appears as part of a body part's headers, it applies only to the body of that body part ๐ง. If an entity is of type "multipart" or "message", the Content-Transfer-Encoding is not permitted to have any value other than a bit width (e.g., "7bit", "8bit", etc.) or "binary" ๐.
It should be noted that email is character-oriented, so that the mechanisms described here are mechanisms for encoding arbitrary octet streams, not bit streams ๐ฆ. If a bit stream is to be encoded via one of these mechanisms, it must first be converted to an 8-bit byte stream using the network standard bit order ("big-endian"), in which the earlier bits in a stream become the higher-order bits in a byte ๐. A bit stream not ending at an 8-bit boundary must be padded with zeroes ๐. This document provides a mechanism for noting the addition of such padding in the case of the application Content-Type, which has a "padding" parameter ๐ .
The encoding mechanisms defined here explicitly encode all data in ASCII ๐ฅ. Thus, for example, suppose an entity has header fields such as:
Content-Type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: base64
This must be interpreted to mean that the body is a base64 ASCII encoding of data that was originally in ISO-8859-1, and will be in that character set again after decoding ๐ญโจ.
The following sections will define the two standard encoding mechanisms ๐. The definition of new content-transfer-encodings is explicitly discouraged and should only occur when absolutely necessary. All content-transfer-encoding namespace except that beginning with "X-" is explicitly reserved to the IANA for future use. Private agreements about content-transfer-encodings are also explicitly discouraged ๐ซถ.
Certain Content-Transfer-Encoding values may only be used on certain Content-Types ๐ธ. In particular, it is expressly forbidden to use any encodings other than "7bit", "8bit", or "binary" with any Content-Type that recursively includes other Content-Type fields, notably the "multipart" and "message" Content-Types ๐. All encodings that are desired for bodies of type multipart or message must be done at the innermost level, by encoding the actual body that needs to be encoded ๐ง.
NOTE ON ENCODING RESTRICTIONS: okay this one is so good ๐ญ. Though the prohibition against using content-transfer-encodings on data of type multipart or message may seem overly restrictive, it is necessary to prevent nested encodings, in which data are passed through an encoding algorithm multiple times, and must be decoded multiple times in order to be properly viewed. Nested encodings add considerable complexity to user agents: aside from the obvious efficiency problems with such multiple encodings, they can obscure the basic structure of a message. In particular, they can imply that several decoding operations are necessary simply to find out what types of objects a message contains. Banning nested encodings may complicate the job of certain mail gateways, but this seems less of a problem than the effect of nested encodings on user agents ๐ .
NOTE ON THE RELATIONSHIP BETWEEN CONTENT-TYPE AND CONTENT-TRANSFER-ENCODING: it may seem that the Content-Transfer-Encoding could be inferred from the characteristics of the Content-Type that is to be encoded, or, at the very least, that certain Content-Transfer-Encodings could be mandated for use with specific Content-Types. There are several reasons why this is not the case ๐. First, given the varying types of transports used for mail, some encodings may be appropriate for some Content-Type/transport combinations and not for others. (For example, in an 8-bit transport, no encoding would be required for text in certain character sets, while such encodings are clearly required for 7-bit SMTP.) Second, certain Content-Types may require different types of transfer encoding under different circumstances. For example, many PostScript bodies might consist entirely of short lines of 7-bit data and hence require little or no encoding. Other PostScript bodies (especially those using Level 2 PostScript's binary encoding mechanism) may only be reasonably represented using a binary transport encoding. Finally, since Content-Type is intended to be an open-ended specification mechanism, strict specification of an association between Content-Types and encodings effectively couples the specification of an application protocol with a specific lower-level transport. This is not desirable since the developers of a Content-Type should not have to be aware of all the transports in use and what their limitations are ๐.
NOTE ON TRANSLATING ENCODINGS: the quoted-printable and base64 encodings are designed so that conversion between them is possible ๐ฆ. The only issue that arises in such a conversion is the handling of line breaks. When converting from quoted-printable to base64 a line break must be converted into a CRLF sequence. Similarly, a CRLF sequence in base64 data must be converted to a quoted-printable line break, but ONLY when converting text data โจ.
NOTE ON CANONICAL ENCODING MODEL: there was some confusion, in earlier drafts of this memo, regarding the model for when email data was to be converted to canonical form and encoded, and in particular how this process would affect the treatment of CRLFs, given that the representation of newlines varies greatly from system to system, and the relationship between content-transfer-encodings and character sets ๐. For this reason, a canonical model for encoding is presented as Appendix G ๐ง.
5.1. Quoted-Printable Content-Transfer-Encoding โจ
Okay bestie, so Quoted-Printable is the encoding for data that's mostly regular printable ASCII characters ๐ . The whole point is that the encoded octets are unlikely to get messed with by mail transport ๐ซถ. If the data is mostly ASCII text, the encoded version still looks pretty readable to humans, which is so iconic ๐. Even a body that's entirely ASCII can be encoded this way, so it survives a character-translating gateway and/or a line-wrapping gateway ๐ฆ.
In this encoding, octets get represented according to the following rules ๐ธ:
Rule #1: (General 8-bit representation) Any octet, except the ones that signal a line break under the newline convention of the canonical (standard) form of the data being encoded, can be written as an "=" followed by a two digit hexadecimal representation of the octet's value ๐ฅ. The hex digits here are "0123456789ABCDEF". Uppercase letters must be used when sending hexadecimal data, though a robust implementation may choose to recognize lowercase letters on receipt. So, for example, the value 12 (ASCII form feed) can be represented by =0C, and the value 61 (ASCII EQUAL SIGN) can be represented by =3D. Unless the following rules allow an alternative encoding, this rule is mandatory ๐.
Rule #2: (Literal representation) Octets with decimal values of 33 through 60 inclusive, and 62 through 126, inclusive, MAY be represented as the ASCII characters that match those octets (EXCLAMATION POINT through LESS THAN, and GREATER THAN through TILDE, respectively) โจ.
Rule #3: (White Space) Octets with values of 9 and 32 MAY be represented as ASCII TAB (HT) and SPACE characters, respectively, but MUST NOT be so represented at the end of an encoded line ๐. Any TAB (HT) or SPACE characters on an encoded line MUST thus be followed on that line by a printable character. In particular, an "=" at the end of an encoded line, which indicates a soft line break (see rule #5), may follow one or more TAB (HT) or SPACE characters. It follows that an octet with value 9 or 32 appearing at the end of an encoded line must be represented according to Rule #1. This rule exists because some MTAs (Message Transport Agents, programs which transport messages from one user to another, or perform a part of such transfers) are known to pad lines of text with SPACEs, and others are known to remove "white space" characters from the end of a line ๐ง. Therefore, when decoding a Quoted-Printable body, any trailing white space on a line must be deleted, as it will necessarily have been added by intermediate transport agents.
Rule #4 (Line Breaks) A line break in a text body must be represented by a (RFC 822) line break, which is a CRLF sequence, in the Quoted-Printable encoding, no matter what it looks like in the canonical representation of the data being encoded ๐. Since the canonical representation of types other than text does not generally include line breaks, no hard line breaks (line breaks that are meant to be meaningful and displayed to the user) should occur in the quoted-printable encoding of such types. Of course, occurrences of =0D, =0A, 0A=0D and =0D=0A will eventually be encountered ๐. In general, though, base64 is preferred over quoted-printable for binary data ๐.
Note that many implementations may elect to encode the local representation of various content types directly, as described in Appendix G ๐. This may apply in particular to plain text material on systems that use newline conventions other than CRLF delimiters. Such an implementation is permissible, but the generation of line breaks must be generalized to account for the case where alternate representations of newline sequences are used.
Rule #5 (Soft Line Breaks) The Quoted-Printable encoding REQUIRES that encoded lines be no more than 76 characters long ๐. If longer lines are to be encoded with Quoted-Printable, 'soft' line breaks must be used. An equal sign as the last character on an encoded line indicates such a non-significant ('soft') line break in the encoded text. So if the "raw" form of the line is a single unencoded line that says:
Now's the time for all folk to come to the aid of
their country.
this can be represented, in the Quoted-Printable encoding, as:
Now's the time =
for all folk to come=
to the aid of their country.
This is the mechanism that lets long lines get encoded in a way the user agent can restore ๐ฆ. The 76 character limit does not count the trailing CRLF, but it does count all other characters, including any equal signs ๐งฎ.
Since the hyphen character ("-") is represented as itself in Quoted-Printable, you have to be careful when wrapping a quoted-printable encoded body in a multipart entity ๐ซฃ. Make sure the encapsulation boundary does not appear anywhere in the encoded body. (A good strategy is to choose a boundary that includes a character sequence such as "=_", which can never appear in a quoted-printable body. See the definition of multipart messages later in this document.)
NOTE: Quoted-Printable is kind of a compromise between readability and reliability in transport ๐. Bodies encoded with it will work reliably over most mail gateways, but may not work perfectly over a few gateways, notably those involving translation into EBCDIC. (In theory, an EBCDIC gateway could decode a quoted-printable body and re-encode it using base64, but such gateways do not yet exist.) A higher level of confidence is offered by the base64 Content-Transfer-Encoding. A way to get reasonably reliable transport through EBCDIC gateways is to also quote the ASCII characters below according to rule #1. See Appendix B for more information.
!"#$@[\]^`{|}~
Because quoted-printable data is generally assumed to be line-oriented, it is to be expected that the representation of the breaks between the lines of quoted-printable data may be altered in transport ๐ท. This happens in the same way plain text mail has always been altered in Internet mail when passing between systems with differing newline conventions. If such alterations are likely to constitute a corruption of the data, it is probably more sensible to use the base64 encoding rather than the quoted-printable encoding ๐.
WARNING TO IMPLEMENTORS: If binary data are encoded in quoted-printable, care must be taken to encode CR and LF characters as=0Dand=0A, respectively ๐จ. In particular, a CRLF sequence in binary data should be encoded as=0D=0A. Otherwise, if CRLF were represented as a hard line break, it might be incorrectly decoded on platforms with different line break conventions. Bestie, this one is a must-read ๐ญ.
For the formalists ๐ค, the syntax of quoted-printable data is described by the following grammar:
quoted-printable := ([*(ptext / SPACE / TAB) ptext] ["="] CRLF)
; Maximum line length of 76 characters excluding CRLF
ptext := octet /<any ASCII character except "=", SPACE, or TAB>
; characters not listed as "mail-safe" in Appendix B
; are also not recommended.
octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F")
; octet must be used for characters > 127, =, SPACE, or TAB,
; and is recommended for any characters not listed in
; Appendix B as "mail-safe".
5.2. Base64 Content-Transfer-Encoding ๐ฆ
okay bestie, Base64 is the encoding for when you're sending arbitrary sequences of octets that don't need to be humanly readable ๐ค The encoding and decoding algorithms are simple, but the encoded data are consistently only about 33 percent larger than the unencoded data. That's giving efficiency ๐
This encoding is virtually identical to the one used in Privacy Enhanced Mail (PEM) applications, as defined in RFC 1421 โจ The base64 encoding is adapted from RFC 1421, with one change: base64 eliminates the "*" mechanism for embedded clear text. Bye bye, "*" ๐
A 65-character subset of US-ASCII is used, enabling 6 bits to be represented per printable character. (The extra 65th character, "=", is used to signify a special processing function ๐ง)
NOTE: This subset has the important property that it is represented identically in all versions of ISO 646, including US ASCII, and all characters in the subset are also represented identically in all versions of EBCDIC. Other popular encodings, such as the encoding used by the uuencode utility and the base85 encoding specified as part of Level 2 PostScript, do not share these properties, and thus do not fulfill the portability requirements a binary transport encoding for mail must meet. Not them being unportable ๐
The encoding process represents 24-bit groups of input bits as output strings of 4 encoded characters. Proceeding from left to right, a 24-bit input group is formed by concatenating 3 8-bit input groups. These 24 bits are then treated as 4 concatenated 6-bit groups, each of which is translated into a single digit in the base64 alphabet. When encoding a bit stream via the base64 encoding, the bit stream must be presumed to be ordered with the most-significant-bit first.
That is, the first bit in the stream will be the high-order bit in the first byte, and the eighth bit will be the low-order bit in the first byte, and so on. It's giving bit-order main character energy ๐
Each 6-bit group is used as an index into an array of 64 printable characters. The character referenced by the index is placed in the output string. These characters, identified in Table 1, below, are selected so as to be universally representable, and the set excludes characters with particular significance to SMTP (e.g., ".", CR, LF) and to the encapsulation boundaries defined in this document (e.g., "-"). So the alphabet is picked to be safe everywhere, no drama ๐
Table 1: The Base64 Alphabet
Value Encoding Value Encoding Value Encoding Value Encoding
0 A 17 R 34 i 51 z
1 B 18 S 35 j 52 0
2 C 19 T 36 k 53 1
3 D 20 U 37 l 54 2
4 E 21 V 38 m 55 3
5 F 22 W 39 n 56 4
6 G 23 X 40 o 57 5
7 H 24 Y 41 p 58 6
8 I 25 Z 42 q 59 7
9 J 26 a 43 r 60 8
10 K 27 b 44 s 61 9
11 L 28 c 45 t 62 +
12 M 29 d 46 u 63 /
13 N 30 e 47 v
14 O 31 f 48 w (pad) =
15 P 32 g 49 x
16 Q 33 h 50 y
The output stream (encoded bytes) must be represented in lines of no more than 76 characters each. All line breaks or other characters not found in Table 1 must be ignored by decoding software. In base64 data, characters other than those in Table 1, line breaks, and other white space probably indicate a transmission error, about which a warning message or even a message rejection might be appropriate under some circumstances. Suspicious characters = potential drama ๐
Special processing is performed if fewer than 24 bits are available at the end of the data being encoded. A full encoding quantum is always completed at the end of a body. When fewer than 24 input bits are available in an input group, zero bits are added (on the right) to form an integral number of 6-bit groups. Padding at the end of the data is performed using the '=' character. Since all base64 input is an integral number of octets, only the following cases can arise: (1) the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters with no "=" padding, (2) the final quantum of encoding input is exactly 8 bits; here, the final unit of encoded output will be two characters followed by two "=" padding characters, or (3) the final quantum of encoding input is exactly 16 bits; here, the final unit of encoded output will be three characters followed by one "=" padding character.
Because it is used only for padding at the end of the data, the occurrence of any '=' characters may be taken as evidence that the end of the data has been reached (without truncation in transit). No such assurance is possible, however, when the number of octets transmitted was a multiple of three. So the = signs are kinda like a "the story ends here" flag, but only sometimes ๐
Any characters outside of the base64 alphabet are to be ignored in base64-encoded data. The same applies to any illegal sequence of characters in the base64 encoding, such as "=====". Ignore the chaos ๐ซถ
Care must be taken to use the proper octets for line breaks if base64 encoding is applied directly to text material that has not been converted to canonical form. In particular, text line breaks must be converted into CRLF sequences prior to base64 encoding. The important thing to note is that this may be done directly by the encoder rather than in a prior canonicalization step in some implementations. Line breaks, the eternal struggle ๐ญ
NOTE: There is no need to worry about quoting apparent encapsulation boundaries within base64-encoded parts of multipart entities because no hyphen characters are used in the base64 encoding. Zero hyphens, zero boundary drama ๐ธ
6. Additional Content-Header Fields โจ
6.1. Optional Content-ID Header Field
In constructing a high-level user agent, it may be desirable to allow one body to make reference to another. Accordingly, bodies may be labeled using the "Content-ID" header field, which is syntactically identical to the "Message-ID" header field:
id := "Content-ID" ":" msg-id
Like the Message-ID values, Content-ID values must be generated to be world-unique. World-unique, like a main character who's one of a kind ๐ฆ
The Content-ID value may be used for uniquely identifying MIME entities in several contexts, particularly for cacheing data referenced by the message/external-body mechanism. Although the Content-ID header is generally optional, its use is mandatory in implementations which generate data of the optional MIME Content-type "message/external-body". That is, each message/external-body entity must have a Content-ID field to permit cacheing of such data. So if you're making external-body entities, the Content-ID is non-negotiable ๐ฅ
It is also worth noting that the Content-ID value has special semantics in the case of the multipart/alternative content-type. This is explained in the section of this document dealing with multipart/alternative. Stay tuned, it's a whole plot twist ๐
6.2. Optional Content-Description Header Field
The ability to associate some descriptive information with a given body is often desirable. For example, it may be useful to mark an "image" body as "a picture of the Space Shuttle Endeavor." Such text may be placed in the Content-Description header field. Space Shuttle Endeavor content, iconic ๐๐
description := "Content-Description" ":" *text
The description is presumed to be given in the US-ASCII character set, although the mechanism specified in [RFC-1522] may be used for non-US-ASCII Content-Description values. Non-ASCII descriptions have a backup plan ๐
7. The Predefined Content-Type Values
This document defines seven initial Content-Type values and an extension mechanism for private or experimental types. Further standard types must be defined by new published specifications. It is expected that most innovation in new types of mail will take place as subtypes of the seven types defined here. The most essential characteristics of the seven content-types are summarized in Appendix F. Seven types, one extension mechanism, and infinite subtype slay ๐โจ
7. Content-Type Header Field โจ
7.1. The Text Content-Type ๐
Okay so text is the Content-Type for stuff that's mostly words ๐ It's the default Content-Type, no cap. A charset parameter can tell you the character set of the body text for some text subtypes, and that includes the big one, text/plain, which means plain, unformatted text. The default Content-Type for Internet mail is text/plain; charset=us-ascii ๐
Beyond plain text, there's "extended text," which is text with formatting and presentation info built in โจ What's so cute about a lot of these formats is that they're still kinda readable even without the software that understands them ๐ฆ So it's useful to sort them at the top level, away from unreadable stuff like images, audio, or text that's been encoded in an unreadable form. Without the right software, it's fine to show text subtypes to the user, but it's not reasonable to do that with most non-text data ๐
Formatted text should use subtypes of text. The plausible subtypes are usually named after the common name of the format, like text/richtext [RFC-1341] ๐
7.1.1. The charset parameter
A critical parameter for text/plain data is the character set ๐ซถ It's set with a charset parameter, like this:
Content-type: text/plain; charset=us-ascii
Unlike some other parameter values, the values of the charset parameter are NOT case sensitive ๐คญ The default character set, which must be assumed when there's no charset parameter, is US-ASCII ๐
Any future subtypes of text have to spell out whether they'll use a charset parameter too, and they might restrict its values as well ๐ When they do, the meaning of charset should be identical to what's described here for text/plain: the body consists entirely of characters in the given charset. Definers of future text subtypes should pay close attention to what multibyte character sets mean for their subtype definitions, because it gets messy fast ๐ง
This RFC defines the charset parameter, for MIME purposes, as a unique mapping of a byte stream to glyphs, and that mapping doesn't need any external profiling information ๐
There's a starter list of predefined character set names at the end of this section ๐ More can be registered with IANA, but making their use a standard needs the usual IESG [RFC-1340] review and approval. Also, if the character set includes 8-bit data, a Content-Transfer-Encoding header field and a corresponding encoding on the data are required to send the body over some mail transfer protocols, like SMTP ๐ฎ
The US-ASCII default has been a whole mess in the past ๐ตโ๐ซ There were ambiguities in the definition and wild variations in practice. To end that drama for good, it's strongly recommended that new user agents explicitly specify a character set via the Content-Type header field ๐ Also, "US-ASCII" doesn't mean some random seven-bit character code. It means the body uses character coding with the exact code-to-character matching specified in ASCII. National variations of ISO 646 [ISO-646] are NOT ASCII, and their use in Internet mail is explicitly discouraged, which is exactly why ISO 646 isn't on the list ๐ โโ๏ธ The character set name "US-ASCII" refers only to ANSI X3.4-1986 [US-ASCII]. And the name "ASCII" is reserved and must not be used for any purpose ๐ซ
NOTE: RFC 821 explicitly specifies "ASCII" and points at an earlier version of the American Standard ๐ One of the whole points of Content-Type and charset is letting the receiver work out exactly how the sender meant the coded message to be read. So treating anything other than "strict ASCII" as the default would risk accidental, incompatible changes to the meaning of messages already being sent ๐ฌ That also means messages with characters coded per national variations of ISO 646, or using code-switching procedures (like those of ISO 2022), as well as 8-bit or multiple octet character encodings, MUST use an appropriate character set specification to stay consistent with this specification ๐
The complete US-ASCII character set is listed in [US-ASCII]. The control characters, including DEL (0-31, 127), have no defined meaning apart from the combination CRLF (ASCII values 13 and 10), which means a new line ๐ธ Two of them have de facto meanings in wide use. FF (12) often means "start subsequent text on the beginning of a new page." TAB or HT (9) often (though not always) means "move the cursor to the next available column after the current position where the column number is a multiple of 8 (counting the first column as column 0)." Apart from that, any use of control characters or DEL in a body must be part of a private agreement between the sender and recipient. Those private agreements are discouraged, and they should be replaced by the other capabilities of this document ๐
NOTE: Beyond US-ASCII, an enormous number of character sets is possible. The IETF working group's opinion is that a large number of character sets is NOT a good thing ๐ They'd prefer to specify a single character set that can be used universally for representing all of the world's languages in electronic mail โจ Unfortunately, existing practice in several communities points to continued use of multiple character sets for the near future. So for that reason, they define names for a small number of character sets with a strong constituent base ๐
The defined charset values are:
US-ASCII-- as defined in [US-ASCII].ISO-8859-X-- where "X" is to be replaced, as necessary, for the parts of ISO-8859 [ISO-8859]. The ISO 646 character sets have deliberately been omitted in favor of their 8859 replacements, which are the designated character sets for Internet mail. As of the publication of this document, the legitimate values for "X" are the digits 1 through 9.
Those character sets were the relatively uncontroversial ones while MIME was being drafted ๐๏ธ This document doesn't endorse any character set other than US-ASCII, and it admits the future of world character sets is still unclear ๐ฎ More character sets are expected to be registered for MIME later on.
Note that the character set used, if it's anything other than US-ASCII, must always be explicitly specified in the Content-Type field ๐
No other character set name may be used in Internet mail without publishing a formal specification and registering it with IANA, or by private agreement. In that second case, the name must begin with "X-" ๐งพ Implementors are discouraged from defining new character sets for mail use unless it's absolutely necessary ๐
The charset parameter was defined mainly for textual data, which is why it's described in this section. Still, non-textual data might want to specify a charset value for some purpose, and in that case the same syntax and values should be used ๐
In general, mail-sending software must always use the "lowest common denominator" character set possible. For example, if a body contains only US-ASCII characters, it must be marked as being in the US-ASCII character set, not ISO-8859-1. ISO-8859-1, like all the ISO-8859 family, is a superset of US-ASCII ๐ง More generally, if a widely-used character set is a subset of another character set, and a body contains only characters in the widely-used subset, it must be labeled as being in that subset. This will increase the chances that the recipient can view the mail correctly ๐ฅฐ
7.1.2. The Text/plain subtype
The primary subtype of text is "plain" ๐ It indicates plain, unformatted text. The default Content-Type for Internet mail, text/plain; charset=us-ascii, describes existing Internet practice. That's the type of body defined by RFC 822 โจ
No other text subtype is defined by this document ๐คท
The formal grammar for the content-type header field for text is as follows:
text-type := "text" "/" text-subtype [";" "charset" "=" charset]
text-subtype := "plain" / extension-token
charset := "us-ascii"/ "iso-8859-1"/ "iso-8859-2"/ "iso-8859-3"
/ "iso-8859-4"/ "iso-8859-5"/ "iso-8859-6"/ "iso-8859-7"
/ "iso-8859-8" / "iso-8859-9" / extension-token
; case insensitive
7.2. The Multipart Content-Type ๐งฉ
When you've got multiple part entities, where one or more different sets of data are combined in a single body, a "multipart" Content-Type field must appear in the entity's header ๐ The body must then contain one or more "body parts," each preceded by an encapsulation boundary, and the last one followed by a closing boundary. Each part starts with an encapsulation boundary, and then contains a body part made of a header area, a blank line, and a body area. So a body part is kinda similar to an RFC 822 message in syntax, but it's different in meaning ๐ซ
A body part is NOT to be interpreted as actually being an RFC 822 message ๐ซ For starters, NO header fields are actually required in body parts. So a body part that starts with a blank line is allowed, and it's a body part where all the default values are to be assumed. In that case, the absence of a Content-Type header field implies that the body is plain US-ASCII text ๐ The only header fields with defined meaning for body parts are the ones whose names begin with "Content-". All other header fields are generally to be ignored in body parts. Although they should generally be retained in mail processing, they may be discarded by gateways if necessary. Those other fields are permitted to appear in body parts, but they must not be depended on ๐ "X-" fields may be created for experimental or private purposes, with the recognition that the information they contain may be lost at some gateways ๐งช
๐ NOTE: okay so the difference between an RFC 822 message and a body part is subtle but SUPER important, bestie ๐ซถ A gateway between Internet and X.400 mail, for example, has to be able to tell apart a body part that contains an image ๐ธ from a body part that contains an encapsulated message whose body is an image. To represent the second one, the body part must haveContent-Type: message, and its body (after the blank line) must be the encapsulated message, with its ownContent-Type: imageheader field. The syntax looks so similar that turning messages into body parts (and back again) is easy, but implementors still need to understand the distinction between the two ๐ (For the special case where all the parts actually are messages, there's also a "digest" subtype ๐ฌ.)
Like I said before ๐, each body part is preceded by an encapsulation boundary ๐ง. The encapsulation boundary MUST NOT appear inside any of the encapsulated parts ๐ โโ๏ธ. So it's crucial that the composing agent can choose and specify the unique boundary that will separate the parts โ๏ธ.
All present and future subtypes of the "multipart" type must use an identical syntax ๐ฏ. Subtypes may differ in their semantics, and may impose additional restrictions on syntax, but they must still conform to the required syntax for the multipart type. This requirement makes sure that all conformant user agents will at least be able to recognize and separate the parts of any multipart entity, even one of an unrecognized subtype ๐ง.
As stated in the definition of the Content-Transfer-Encoding field, no encoding other than "7bit", "8bit", or "binary" is permitted for entities of type "multipart" ๐ซ. The multipart delimiters and header fields are always represented as 7-bit ASCII in any case (though the header fields may encode non-ASCII header text as per [RFC-1522]), and data within the body parts can be encoded on a part-by-part basis, with Content-Transfer-Encoding fields for each appropriate body part ๐.
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. Such alterations are explicitly forbidden for the body part headers embedded in the bodies of messages of type "multipart".
7.2.1. Multipart: The common syntax โจ
All subtypes of "multipart" share a common syntax, and that syntax is defined in this section ๐งฉ. A simple example of a multipart message also appears in this section. An example of a more complex multipart message is given in Appendix C ๐.
The Content-Type field for multipart entities requires one parameter, "boundary", which is used to specify the encapsulation boundary ๐ฏ. The encapsulation boundary is defined as a line consisting entirely of two hyphen characters ("-", decimal code 45) followed by the boundary parameter value from the Content-Type header field.
๐ง NOTE: The hyphens are there for rough compatibility with the earlier RFC 934 method of message encapsulation, and for ease of searching for the boundaries in some implementations. However, it should be noted that multipart messages are NOT completely compatible with RFC 934 encapsulations. In particular, they do not obey RFC 934 quoting conventions for embedded lines that begin with hyphens. This mechanism was chosen over the RFC 934 mechanism because the latter causes lines to grow with each level of quoting. The combination of this growth with the fact that SMTP implementations sometimes wrap long lines made the RFC 934 mechanism unsuitable for use in the event that deeply-nested multipart structuring is ever desired.
โ ๏ธ WARNING TO IMPLEMENTORS: The grammar for parameters on the Content-type field is such that it is often necessary to enclose the boundaries in quotes on the Content-type line. This is not always necessary, but never hurts. Implementors should be sure to study the grammar carefully in order to avoid producing illegal Content-type fields. Thus, a typical multipart Content-Type header field might look like this:
Content-Type: multipart/mixed;
boundary=gc0p4Jq0M2Yt08jU534c0p
But the following is illegal ๐ โโ๏ธ:
Content-Type: multipart/mixed;
boundary=gc0p4Jq0M:2Yt08jU534c0p
(because of the colon) and it must instead be represented as
Content-Type: multipart/mixed;
boundary="gc0p4Jq0M:2Yt08jU534c0p"
This indicates that the entity consists of several parts, each itself with a structure that is syntactically identical to an RFC 822 message, except that the header area might be completely empty. The parts are each preceded by the line ๐ง
--gc0p4Jq0M:2Yt08jU534c0p
Note that the encapsulation boundary must occur at the beginning of a line, i.e., following a CRLF. The initial CRLF is considered to be attached to the encapsulation boundary rather than part of the preceding part ๐. The boundary must be followed immediately either by another CRLF and the header fields for the next part, or by two CRLFs, in which case there are no header fields for the next part (and it is therefore assumed to be of Content-Type text/plain).
๐ก NOTE: The CRLF preceding the encapsulation line is conceptually attached to the boundary, so that it is possible to have a part that does not end with a CRLF (line break). Body parts that must be considered to end with line breaks, therefore, must have two CRLFs preceding the encapsulation line. The first of those is part of the preceding body part, and the second is part of the encapsulation boundary.
Encapsulation boundaries must not appear within the encapsulations, and must be no longer than 70 characters, not counting the two leading hyphens ๐.
The encapsulation boundary following the last body part is a distinguished delimiter that indicates that no further body parts will follow ๐. Such a delimiter is identical to the previous delimiters, with the addition of two more hyphens at the end of the line:
--gc0p4Jq0M2Yt08jU534c0p--
There appears to be room for additional information prior to the first encapsulation boundary and following the final boundary. These areas should generally be left blank, and implementations must ignore anything that appears before the first boundary or after the last one ๐ซง.
๐ NOTE: These "preamble" and "epilogue" areas are generally not used, because of the lack of proper typing of these parts and the lack of clear semantics for handling these areas at gateways, particularly X.400 gateways. However, rather than leaving the preamble area blank, many MIME implementations have found this to be a convenient place to insert an explanatory note for recipients who read the message with pre-MIME software, since such notes will be ignored by MIME-compliant software.
๐ NOTE: Because encapsulation boundaries must not appear in the body parts being encapsulated, a user agent must exercise care to choose a unique boundary. The boundary in the example above could have been the result of an algorithm designed to produce boundaries with a very low probability of already existing in the data to be encapsulated, without having to prescan the data. Alternate algorithms might result in more 'readable' boundaries for a recipient with an old user agent, but would require more attention to the possibility that the boundary might appear in the encapsulated part. The simplest boundary possible is something like "---", with a closing boundary of "-----".
As a very simple example, the following multipart message has two parts, both of them plain text, one of them explicitly typed and one of them implicitly typed ๐
From: Nathaniel Borenstein <nsb@bellcore.com>
To: Ned Freed <ned@innosoft.com>
Subject: Sample message
MIME-Version: 1.0
Content-type: multipart/mixed; boundary="simple
boundary"
This is the preamble. It is to be ignored, though it
is a handy place for mail composers to include an
explanatory note to non-MIME conformant readers.
--simple boundary
This is implicitly typed plain ASCII text.
It does NOT end with a linebreak.
--simple boundary
Content-type: text/plain; charset=us-ascii
This is explicitly typed plain ASCII text.
It DOES end with a linebreak.
--simple boundary--
This is the epilogue. It is also to be ignored.
The use of a Content-Type of multipart in a body part within another multipart entity is explicitly allowed ๐ช. In such cases, for obvious reasons, care must be taken to ensure that each nested multipart entity must use a different boundary delimiter. See Appendix C for an example of nested multipart entities.
The use of the multipart Content-Type with only a single body part may be useful in certain contexts, and it is explicitly permitted ๐ฆ.
The only mandatory parameter for the multipart Content-Type is the boundary parameter ๐. It consists of 1 to 70 characters from a set of characters known to be very robust through email gateways, and it is NOT ending with white space. (If a boundary appears to end with white space, the white space must be presumed to have been added by a gateway, and must be deleted.) It is formally specified by the following BNF:
boundary := 0*69<bchars> bcharsnospace
bchars := bcharsnospace / " "
bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" /"_"
/ "," / "-" / "." / "/" / ":" / "=" / "?"
Overall, the body of a multipart entity may be specified as follows ๐ธ
multipart-body := preamble 1*encapsulation
close-delimiter epilogue
encapsulation := delimiter body-part CRLF
delimiter := "--" boundary CRLF ; taken from Content-Type field.
; There must be no space
; between "--" and boundary.
close-delimiter := "--" boundary "--" CRLF ; Again, no space
by "--",
preamble := discard-text ; to be ignored upon receipt.
epilogue := discard-text ; to be ignored upon receipt.
discard-text := *(*text CRLF)
body-part := <"message" as defined in RFC 822,
with all header fields optional, and with the
specified delimiter not occurring anywhere in
the message body, either on a line by itself
or as a substring anywhere. Note that the
semantics of a part differ from the semantics
of a message, as described in the text.>
๐ NOTE: In certain transport enclaves, RFC 822 restrictions such as the one that limits bodies to printable ASCII characters may not be in force. (That is, the transport domains may resemble standard Internet mail transport as specified in RFC821 and assumed by RFC822, but without certain restrictions.) The relaxation of these restrictions should be construed as locally extending the definition of bodies, for example to include octets outside of the ASCII range, as long as these extensions are supported by the transport and adequately documented in the Content-Transfer-Encoding header field. However, in no event are headers (either message headers or body-part headers) allowed to contain anything other than ASCII characters ๐จ
NOTE: Okay so, the multipart type is lowkey missing any notion of structured, related body parts, and that's on purpose. Standardizing interpart structure is considered premature for now. It is RECOMMENDED that anyone wanting a more structured or integrated multipart messaging facility SHOULD define a subtype that is syntactically identical, but that always expects a distinguished part that specifies the structure and integration of the other parts, probably by referring to them through their Content-ID field. If you go this route, other implementations won't recognize the new subtype, but they'll treat it as the primary subtype (multipart/mixed) and will still be able to show the user the parts they do recognize. ๐งฉ
7.2.2. The Multipart/mixed (primary) subtype ๐
The primary subtype for multipart, "mixed", is for when the body parts are independent and need to be bundled in a particular order. Any multipart subtypes that an implementation does not recognize MUST be treated as being of subtype "mixed". ๐
7.2.3. The Multipart/alternative subtype ๐ฆ
The multipart/alternative type is syntactically identical to multipart/mixed, but the semantics are different. Specifically, each part is an "alternative" version of the same information. It's giving "same vibe, different outfit" energy. ๐
Systems SHOULD recognize that the content of the various parts is interchangeable. Systems SHOULD choose the "best" type based on the local environment and preferences, sometimes even through user interaction. Just like with multipart/mixed, the order of body parts matters. Here the alternatives show up in order of increasing faithfulness to the original content. In general, the best choice is the LAST part of a type supported by the recipient system's local environment. โจ
Multipart/alternative MAY be used, for example, to send mail in a fancy text format in a way that can easily be displayed anywhere:
From: Nathaniel Borenstein <nsb@bellcore.com>
To: Ned Freed <ned@innosoft.com>
Subject: Formatted text mail
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary=boundary42
--boundary42
Content-Type: text/plain; charset=us-ascii
...plain text version of message goes here....
--boundary42
Content-Type: text/richtext
.... RFC 1341 richtext version of same message goes here ...
--boundary42
Content-Type: text/x-whatever
.... fanciest formatted version of same message goes here
...
--boundary42--
In this example, users whose mail system understood the text/x-whatever format would see only the fancy version, while everyone else would see only the richtext or plain text version, depending on what their system can handle. ๐ธ
In general, user agents that compose multipart/alternative entities MUST place the body parts in increasing order of preference, meaning the preferred format goes last. For fancy text, the sending user agent SHOULD put the plainest format first and the richest format last. Receiving user agents SHOULD pick and display the last format they're capable of displaying. If one of the alternatives is itself of type "multipart" and contains unrecognized sub-parts, the user agent MAY choose to show that alternative, an earlier alternative, or both. ๐ซถ
NOTE: From an implementor's perspective, it might seem more sensible to reverse this ordering and have the plainest alternative last. However, placing the plainest alternative first is the friendliest possible option when multipart/alternative entities are viewed using a non-MIME-conformant mail reader. While this approach does put some burden on conformant mail readers, interoperability with older mail readers was deemed more important in this case. ๐
It MAY be the case that some user agents, if they can recognize more than one of the formats, will prefer to offer the user a choice of which format to view. This makes sense, for example, if mail includes both a nicely-formatted image version and an easily-edited text version. What's most critical, though, is that the user is not automatically shown multiple versions of the same data. Either the user SHOULD be shown the last recognized version or SHOULD be given the choice. ๐
NOTE ON THE SEMANTICS OF CONTENT-ID IN MULTIPART/ALTERNATIVE: Each part of a multipart/alternative entity represents the same data, but the mappings between the two aren't necessarily without information loss. For example, information is lost when translating ODA to PostScript or plain text. It is RECOMMENDED that each part SHOULD have a different Content-ID value in cases where the information content of the two parts is not identical. However, where the information content is identical (for example, where several parts of type "application/external-body" specify alternate ways to access the identical data), the same Content-ID field value SHOULD be used, to optimize any caching mechanisms that might be present on the recipient's end. However, it is RECOMMENDED that the Content-ID values used by the parts SHOULD NOT be the same Content-ID value that describes the multipart/alternative as a whole, if there is any such Content-ID field. In other words, one Content-ID value refers to the multipart/alternative entity, while one or more other Content-ID values refer to the parts inside it. ๐ง
7.2.4. The Multipart/digest subtype ๐ฐ
This document defines a "digest" subtype of the multipart Content-Type. This type is syntactically identical to multipart/mixed, but the semantics are different. Specifically, in a digest, the default Content-Type value for a body part changes from "text/plain" to "message/rfc822". This makes for a more readable digest format that's largely compatible (except for the quoting convention) with RFC 934. ๐ฌ
A digest in this format might, then, look something like this:
From: Moderator-Address
To: Recipient-List
MIME-Version: 1.0
Subject: Internet Digest, volume 42
Content-Type: multipart/digest;
boundary="---- next message ----"
------ next message ----
From: someone-else
Subject: my opinion
...body goes here ...
------ next message ----
From: someone-else-again
Subject: my different opinion
... another body goes here...
------ next message ------
7.2.5. The Multipart/parallel subtype ๐ง
This document defines a "parallel" subtype of the multipart Content-Type. This type is syntactically identical to multipart/mixed, but the semantics are different. Specifically, in a parallel entity, the order of body parts is not significant. ๐
A common way to present this type is to display all the parts simultaneously on hardware and software that can do so. However, composing agents SHOULD be aware that many mail readers will lack this capability and will show the parts serially anyway. ๐ฅน
7.2.6. Other Multipart subtypes ๐
Other multipart subtypes are expected in the future. MIME implementations MUST in general treat unrecognized subtypes of multipart as being equivalent to "multipart/mixed".
The formal grammar for content-type header fields for multipart data is given by:
multipart-type := "multipart" "/" multipart-subtype
";" "boundary" "=" boundary
multipart-subtype := "mixed" / "parallel" / "digest"
/ "alternative" / extension-token
7.3. The Message Content-Type ๐จ
It's super common, when sending mail, to encapsulate another mail message. For this everyday move, there's a special Content-Type called "message". The primary subtype, message/rfc822, has no REQUIRED parameters in the Content-Type field. The additional subtypes, "partial" and "External-body", do have REQUIRED parameters. We'll go through these subtypes below. ๐
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, where 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 this way preserves the type information on the original message and allows it to be correctly presented to the recipient, which is why it's strongly encouraged. ๐ซ
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. 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].
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. Such alterations are explicitly forbidden for the encapsulated headers embedded in the bodies of messages of type "message". ๐ซ
7.3.1. The Message/rfc822 (primary) subtype ๐ซ
A Content-Type of "message/rfc822" indicates that the body contains an encapsulated message, with the syntax of an RFC 822 message. However, unlike top-level RFC 822 messages, it is not REQUIRED that each message/rfc822 body MUST include a "From", "Subject", and at least one destination header. ๐
It should be noted that, despite the use of the numbers "822", a message/rfc822 entity can include enhanced information as defined in this document. In other words, a message/rfc822 message MAY be a MIME message. ๐ฆ
7.3.2. The Message/Partial subtype ๐งฉ
A subtype of message, "partial", is defined so that large objects can be delivered as several separate pieces of mail and automatically reassembled by the receiving user agent. (The concept is similar to IP fragmentation/reassembly in the basic Internet Protocols.) This mechanism can be used when intermediate transport agents limit the size of individual messages that can be sent. Content-Type "message/partial" thus indicates that the body contains a fragment of a larger message. โ๏ธ
Three parameters MUST be specified in the Content-Type field of type message/partial. The first, "id", is a unique identifier, as close to a world-unique identifier as possible, used to match the parts together. (In general, the identifier is essentially a message-id. If placed in double quotes, it can be any message-id, in accordance with the BNF for "parameter" given earlier in this specification.) The second, "number", an integer, is the part number, which indicates where this part fits into the sequence of fragments. The third, "total", another integer, is the total number of parts. This third subfield is REQUIRED on the final part, and is OPTIONAL (though encouraged) on the earlier parts. Note also that these parameters MAY be given in any order. ๐
Thus, part 2 of a 3-part message may have either of the following header fields:
Content-Type: Message/Partial;
number=2; total=3;
id="oc=jpbe0M2Yt4s@thumper.bellcore.com"
Content-Type: Message/Partial;
id="oc=jpbe0M2Yt4s@thumper.bellcore.com";
number=2
Okay bestie, but part 3 MUST specify the total number of parts ๐ซถ:
Content-Type: Message/Partial;
number=3; total=3;
id="oc=jpbe0M2Yt4s@thumper.bellcore.com"
Note that part numbering starts at 1, not 0. Counting from zero is giving chaos ๐
Once all the pieces are stitched back together โจ, you get a complete MIME entity! It can have its own Content-Type header field, so it can literally hold any other data type ๐
Message fragmentation and reassembly: The semantics of a reassembled partial message must be those of the "inner" message, rather than of a message containing the inner message. This is so iconic, because you can send a huge audio message in chunks and the recipient just sees a normal audio message, not an audio message wrapped up inside another message. The encapsulation is considered to be "transparent" ๐ฆ
When you generate and reassemble the parts of a message/partial message, the headers of the encapsulated message must be merged with the headers of the enclosing entities. The following rules must be observed:
- All of the header fields from the initial enclosing entity (part one), except those that start with
Content-and the specific header fieldsMessage-ID,Encrypted, andMIME-Version, must be copied, in order, to the new message. - Only those header fields in the enclosed message which start with
Content-andMessage-ID,Encrypted, andMIME-Versionmust be appended, in order, to the header fields of the new message. Any header fields in the enclosed message which do not start withContent-(except forMessage-ID,Encrypted, andMIME-Version) will be ignored. - All of the header fields from the second and any subsequent messages will be ignored.
Here's an example ๐ If an audio message is broken into two parts, the first part might look something like this:
X-Weird-Header-1: Foo
From: Bill@host.com
To: joe@otherhost.com
Subject: Audio mail
Message-ID: <id1@host.com>
MIME-Version: 1.0
Content-type: message/partial;
id="ABC@host.com";
number=1; total=2
X-Weird-Header-1: Bar
X-Weird-Header-2: Hello
Message-ID: <anotherid@foo.com>
MIME-Version: 1.0
Content-type: audio/basic
Content-transfer-encoding: base64
... first half of encoded audio data goes here...
And the second half might look something like this:
From: Bill@host.com
To: joe@otherhost.com
Subject: Audio mail
MIME-Version: 1.0
Message-ID: <id2@host.com>
Content-type: message/partial;
id="ABC@host.com"; number=2; total=2
... second half of encoded audio data goes here...
Then, when the fragmented message gets reassembled, the result that gets shown to the user should look something like this ๐:
X-Weird-Header-1: Foo
From: Bill@host.com
To: joe@otherhost.com
Subject: Audio mail
Message-ID: <anotherid@foo.com>
MIME-Version: 1.0
Content-type: audio/basic
Content-transfer-encoding: base64
... first half of encoded audio data goes here...
... second half of encoded audio data goes here...
Note on encoding of MIME entities encapsulated inside message/partial entities: Data of type "message" may never be encoded in base64 or quoted-printable ๐ญ. That means a problem can pop up if message/partial entities get built in an environment that supports binary or 8-bit transport. The binary data would be split into multiple message/partial objects, and each of them would need binary transport. If those objects hit a gateway going into a 7-bit transport environment, there'd be no proper way to encode them for the 7-bit world, unless you waited for all the parts, reassembled the message, and then encoded the reassembled data in base64 or quoted-printable. Since different parts might go through different gateways, even that isn't an acceptable solution ๐. So, for this reason, MIME entities of type message/partial must always have a content-transfer-encoding of 7-bit (the default). Even in environments that support binary or 8-bit transport, using a content-transfer-encoding of 8bit or binary is explicitly prohibited for entities of type message/partial.
It should be noted that some message transfer agents may choose to automatically fragment large messages, and those agents may use different fragmentation thresholds. Because of that, the pieces of a partial message might, once reassembled, turn out to comprise a partial message themselves. This is explicitly permitted ๐ธ
It should also be noted that including a References field in the headers of the second and subsequent pieces of a fragmented message, one that references the Message-Id on the previous piece, may be of benefit to mail readers that understand and track references. However, generating such References fields is entirely optional.
Finally, the Encrypted header field has been made obsolete by Privacy Enhanced Messaging (PEM). The rules above are still believed to describe the correct way to treat it if it shows up in the context of converting to and from message/partial fragments.
7.3.3. The Message/External-Body subtype โจ
The external-body subtype says that the actual body data are not included, just referenced ๐ฆ. In this case, the parameters describe a mechanism for accessing the external data.
When an entity is of type "message/external-body", it consists of a header, two consecutive CRLFs, and the message header for the encapsulated message. If another pair of consecutive CRLFs shows up, that ends the message header for the encapsulated message, of course. However, since the encapsulated message's body is itself external, it does not appear in the area that follows. For example, consider the following message:
Content-type: message/external-body; access-
type=local-file;
name="/u/nsb/Me.gif"
Content-type: image/gif
Content-ID: <id42@guppylake.bellcore.com>
Content-Transfer-Encoding: binary
THIS IS NOT REALLY THE BODY!
The area at the end, which you could call the "phantom body" ๐ป, gets ignored for most external-body messages. However, it can be used to hold auxiliary information for some of those messages, and it does get used that way when the access-type is "mail-server". Of the access-types defined by this document, the phantom body is used only when the access-type is "mail-server". In all other cases, the phantom body is ignored.
The only always-mandatory parameter for message/external-body is "access-type". All of the other parameters may be mandatory or optional, depending on the value of access-type.
- ACCESS-TYPE -- A case-insensitive word that indicates the supported access mechanism by which the file or data may be obtained. Values include, but are not limited to, "FTP", "ANON-FTP", "TFTP", "AFS", "LOCAL-FILE", and "MAIL-SERVER". Future values, except for experimental values beginning with "X-", must be registered with IANA, as described in Appendix E.
In addition, the following three parameters are optional for all access-types:
- EXPIRATION -- The date (in the RFC 822 "date-time" syntax, as extended by RFC 1123 to permit 4 digits in the year field) after which the existence of the external data is not guaranteed.
- SIZE -- The size (in octets) of the data. The point of this parameter is to help the recipient decide whether or not it's worth spending the resources to retrieve the external data. Note that this describes the size of the data in its canonical form, that is, before any
Content-Transfer-Encodinghas been applied, or after the data have been decoded. - PERMISSION -- A case-insensitive field that indicates whether or not clients might also try to overwrite the data. By default, or if permission is "read", the assumption is that they won't, and that if the data is retrieved once, it's never needed again. If PERMISSION is "read-write", this assumption is invalid, and any local copy must be considered no more than a cache. "Read" and "Read-write" are the only defined values of permission.
The precise semantics of the access-types defined here are described in the sections that follow ๐ง
The encapsulated headers in all message/external-body entities MUST include a Content-ID header field, which gives a unique identifier to reference the data by. This identifier may be used for caching mechanisms, and for recognizing the receipt of the data when the access-type is "mail-server" ๐
Note that, as specified here, the tokens that describe external-body data, such as file names and mail server commands, are required to be in the US-ASCII character set. If this turns out to be problematic in practice, a new mechanism may be required as a future extension to MIME, either as newly defined access-types for message/external-body or by some other mechanism.
As with message/partial, it is specified that MIME entities of type message/external-body must always have a content-transfer-encoding of 7-bit (the default). Even in environments that support binary or 8-bit transport, using a content-transfer-encoding of 8bit or binary is explicitly prohibited for entities of type message/external-body. ๐ฅ
7.3.3.1. The "ftp" and "tftp" access-types ๐
okay so an access-type of FTP or TFTP means the body isn't actually inside the message. it's sitting as a file you can grab with the FTP [RFC-959] or TFTP [RFC-783] protocols ๐ฆ these two need some mandatory params, no cap:
- NAME -- the name of the file that holds the actual body data ๐
- SITE -- a machine you can fetch that file from using the given protocol. this must be a fully qualified domain name, not a nickname ๐
before any data gets pulled over FTP, the user will generally need to be asked for a login id and password for the machine named in SITE. for security reasons, the id and password are not content-type parameters, they must be obtained from the user ๐
then there are some optional ones too:
- DIRECTORY -- a directory the data named by NAME should be retrieved from ๐ธ
- MODE -- a case-insensitive string for the mode you use when retrieving the info โจ for access-type TFTP, the legal values are
NETASCII,OCTET, andMAIL, as set out in the TFTP protocol [RFC-783]. for access-type FTP, the legal values areASCII,EBCDIC,IMAGE, andLOCALn, where n is a decimal integer, typically 8. these match the FTP representation types "A", "E", "I", and "L n" from [RFC-959]. heads up:BINARYandTENEXare not valid MODE values, soOCTET,IMAGE, orLOCAL8should be used instead ๐ and if MODE isn't specified, the default isNETASCIIfor TFTP andASCIIotherwise ๐
7.3.3.2. The "anon-ftp" access-type ๐
the anon-ftp access-type is basically the same as ftp, except the user doesn't need to be asked for a name and password for that site ๐ซถ instead, the ftp protocol will be used with login "anonymous" and a password that corresponds to the user's email address. so easy, lowkey iconic โญ
7.3.3.3. The "local-file" and "afs" access-types ๐ง
a local-file access-type means the actual body is a file on the local machine. an afs access-type means the file is reachable through the global AFS file system. in both cases, only one parameter is required:
- NAME -- the name of the file that holds the actual body data ๐
there's also one optional parameter that describes where the data is expected to be visible, aka the site or sites where the file should show up:
- SITE -- a domain specifier for a machine or set of machines known to have access to the data file. asterisks can be used for wildcard matching on part of a domain name, like
*.bellcore.com, to mean a set of machines where the data should be directly visible. a single asterisk can be used to mean a file that's expected to be universally available, e.g., via a global file system ๐
7.3.3.4. The "mail-server" access-type ๐
the mail-server access-type means the actual body is available from a mail server. the mandatory parameter here is:
- SERVER -- the email address of the mail server the actual body data can be obtained from ๐ฌ
because mail servers accept a bunch of different syntaxes (some of them multiline, yikes ๐ญ), the full command to send isn't included as a parameter on the content-type line. instead, it goes in the "phantom body" when the content-type is message/external-body and the access-type is mail-server ๐
one optional parameter for this access-type is:
- SUBJECT -- the subject to use in the mail that gets sent to obtain the data. note that keying mail servers on Subject lines is NOT recommended, but such mail servers are known to exist ๐
quick reminder: MIME doesn't define a mail server syntax. it just lets you include arbitrary mail server commands in the phantom body. implementations must include the phantom body in the body of the message they send to the mail server address to retrieve the relevant data ๐จ
also, unlike the other access-types, mail-server access is asynchronous and happens at an unpredictable time in the future โณ so there has to be a way to match the returned data up with the original message/external-body entity. MIME mailservers must use the same Content-ID field on the returned message that was used in the original message/external-body entity, so the matching actually works ๐ฆ
7.3.3.5. Examples and Further Explanations ๐
with very wide-area file systems popping up, it gets super hard to know ahead of time which machines can and can't see a file directly ๐ตโ๐ซ so it can make sense to give both a file name, to try directly, and the name of one or more sites where the file is known to be accessible. an implementation can try to grab remote files using FTP or any other protocol, using anonymous retrieval or by prompting the user for the name and password. if an external body is accessible through multiple mechanisms, the sender can include multiple parts of type message/external-body inside an entity of type multipart/alternative ๐ฅ
and the external-body mechanism isn't meant to be limited to file retrieval, as the mail-server access-type shows. you could even imagine a video server being used for external references to video clips ๐ฌ
if an entity is of type "message/external-body", the body of the entity contains the header fields of the encapsulated message, and the actual body lives in the external location. this means that if the body of the message/external-body message contains two consecutive CRLFs, everything after those pairs is NOT part of the message itself. for most message/external-body messages, that trailing area must simply be ignored. but it's a handy spot for extra data that can't fit in the content-type header field. in particular, if the access-type value is "mail-server", the trailing area must contain commands to be sent to the mail server at the address given by the SERVER parameter ๐ซถ
the embedded message header fields in the body of the message/external-body data must be used to declare the Content-type of the external body if it's anything other than plain ASCII text, since the external body has no header section to declare its type. likewise, any Content-transfer-encoding other than "7bit" must also be declared here. so a complete message/external-body message, referring to a PostScript document, might look like this ๐
From: Whomever
To: Someone
Subject: whatever
MIME-Version: 1.0
Message-ID: <id1@host.com>
Content-Type: multipart/alternative; boundary=42
Content-ID: <id001@guppylake.bellcore.com>
--42
Content-Type: message/external-body;
name="BodyFormats.ps";
site="thumper.bellcore.com";
access-type=ANON-FTP;
directory="pub";
mode="image";
expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
Content-type: application/postscript
Content-ID: <id42@guppylake.bellcore.com>
--42
Content-Type: message/external-body;
name="/u/nsb/writing/rfcs/RFC-MIME.ps";
site="thumper.bellcore.com";
access-type=AFS
expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
Content-type: application/postscript
Content-ID: <id42@guppylake.bellcore.com>
--42
Content-Type: message/external-body;
access-type=mail-server
server="listserv@bogus.bitnet";
expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)"
Content-type: application/postscript
Content-ID: <id42@guppylake.bellcore.com>
get RFC-MIME.DOC
--42--
in the examples above, the default Content-transfer-encoding of "7bit" is assumed for the external postscript data ๐ธ
like the message/partial type, message/external-body is meant to be transparent. it conveys the data type of the external body, rather than a message with a body of that type. so the headers on the outer and inner parts must be merged using the same rules as for message/partial. specifically, the Content-type header gets overridden, but the From and Subject headers are preserved ๐
since external bodies aren't transported as mail, they don't need to follow the 7-bit and line length requirements, and they might actually be binary files. so a Content-Transfer-Encoding isn't generally necessary, though it's permitted ๐ง
the body of a message of type "message/external-body" is governed by the basic syntax for an RFC 822 message. anything before the first consecutive pair of CRLFs is header information, while anything after it is body information, which gets ignored for most access-types ๐ฆ
here's the formal grammar for content-type header fields for data of type message ๐
message-type := "message" "/" message-subtype
message-subtype := "rfc822"
/ "partial" 2#3partial-param
/ "external-body" 1*external-param
/ extension-token
partial-param := (";" "id" "=" value)
/ (";" "number" "=" 1*DIGIT)
/ (";" "total" "=" 1*DIGIT)
; id & number required; total required for last part
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
/ (";" "name" "=" value)
/ (";" "site" "=" value)
/ (";" "dir" "=" value)
/ (";" "mode" "=" value)
/ (";" "server" "=" value)
/ (";" "subject" "=" value)
; access-type required;others required based on access-type
atype := "ftp" / "anon-ftp" / "tftp" / "local-file"
/ "afs" / "mail-server" / extension-token
; Case-insensitive
7.4. The Application Content-Type โจ
okay so the "application" Content-Type is basically the catch-all ๐งบ for data that doesn't fit in any of the other categories. It's especially for stuff that gets processed by mail-based uses of application programs ๐ป. This is info an application has to crunch before a human can actually view or use it ๐ซถ. Expected uses include mail-based file transfer, spreadsheets, data for mail-based scheduling systems, and languages for "active" (computational) email. The active email one is a big deal ๐ญ because it can cause security problems that implementors need to understand. Those problems are covered in detail in the application/PostScript section.
For example, a meeting scheduler might define a standard way to represent info about proposed meeting dates ๐ . An intelligent user agent could use that info to chat with the user, then send more mail based on that convo ๐ฌ. Honestly, there have been several "active" messaging languages where programs written in a specialized language get sent through the mail and run automatically in the recipient's environment. Wild, right? ๐
Applications like these can be defined as subtypes of the "application" Content-Type. This document defines two subtypes: octet-stream, and PostScript ๐ธ.
The subtype of application will often be the name of the application the data is meant for ๐. That doesn't mean any application program name can be used freely as a subtype, though. Those usages (other than subtypes beginning with "x-") must be registered with IANA, as described in Appendix E ๐.
7.4.1. The Application/Octet-Stream (primary) subtype ๐
The primary subtype of application, "octet-stream", can be used to say that a body contains binary data ๐ง . The possible parameters include, but aren't limited to:
- TYPE -- the general type or category of the binary data. This is for the human recipient, not for any automatic processing ๐.
- PADDING -- the number of bits of padding that got appended to the bit-stream holding the actual contents, so the result is byte-oriented data ๐งฉ. This is handy for enclosing a bit-stream in a body when the total number of bits isn't a multiple of the byte size.
An extra parameter, "conversions", was defined in [RFC-1341] but has since been removed ๐๏ธ.
RFC 1341 also defined a "NAME" parameter that gave a suggested file name in case the data was going to be written to a file. That one's been deprecated, in anticipation of a separate Content-Disposition header field that will be defined in a later RFC ๐ฎ.
The recommended action for an implementation that receives application/octet-stream mail is to simply offer to put the data in a file, with any Content-Transfer-Encoding undone ๐. Or it can use the data as input to a user-specified process, which is also fine โจ.
Now for the real talk ๐จ. To reduce the danger of rogue programs sneaking in through the mail, it is strongly recommended that implementations NOT implement a path-search mechanism. That's the thing where an arbitrary program named in the Content-Type parameter (for example, an interpreter= parameter) gets found and executed using the mail body as input. Do not let your mail client go hunting for random programs and running them ๐๐
โโ๏ธ.
7.4.2. The Application/PostScript subtype ๐จ๏ธ
A Content-Type of "application/postscript" means the body is a PostScript program ๐. Two variants of the PostScript language are currently allowed. The original level 1 variant is described in [POSTSCRIPT], and the newer level 2 variant is described in [POSTSCRIPT2] ๐ .
PostScript is a registered trademark of Adobe Systems, Inc. Using the MIME content-type "application/postscript" implies recognition of that trademark and all the rights it comes with ๐โโ๏ธยฉ๏ธ.
The PostScript language has built-in facilities for labeling the specific language features a given program uses. This labeling, called the PostScript document structuring conventions, is super general and gives way more info than just the language level ๐ท๏ธ.
Using document structuring conventions isn't required, but it's strongly recommended as an aid to interoperability ๐ค. Documents without proper structuring conventions can't be tested to see whether they'll work in a given environment. Because of that, some systems may assume the worst and refuse to process unstructured documents ๐ โโ๏ธ.
โ ๏ธ Security warning, bestie, please read this part. Running general-purpose PostScript interpreters comes with serious security risks, so implementors are discouraged from just sending PostScript email bodies to "off-the-shelf" interpreters. Sending PostScript to a printer is usually safe, since the potential for harm is greatly limited there. Still, implementors should consider all of the following before they add interactive display of PostScript bodies to their mail readers ๐.
The rest of this section outlines some (though probably not all) of the possible problems with sending PostScript through the mail ๐ต๏ธโโ๏ธ.
Dangerous operations in the PostScript language include, but may not be limited to, the operators deletefile, renamefile, filenameforall, and file ๐ฌ. file is only dangerous when it's applied to something other than standard input or output. Implementations may also define additional nonstandard file operators, and these may pose a threat to security too ๐ฉ. filenameforall, the wildcard file search operator, might look harmless at first glance. But it has the potential to reveal which files the recipient has access to, and that info could be sensitive itself ๐๏ธ. Message senders should avoid potentially dangerous file operators, since they're pretty likely to be unavailable in secure PostScript implementations ๐. Message-receiving and -displaying software should either completely disable all potentially dangerous file operators, or take special care not to delegate any special authority to their operation. These operators should be treated as if they're done by an outside agency when interpreting PostScript documents ๐ด๏ธ. That disabling and/or checking should happen completely outside the reach of the PostScript language itself. Care should be taken to make sure there's no method for re-enabling full-function versions of these operators ๐งฑ.
PostScript has facilities for exiting the normal interpreter, or server, loop. Changes made in this "outer" environment are customarily kept across documents, and in some cases they may be kept semipermanently in nonvolatile memory ๐พ. The operators tied to exiting the interpreter loop can interfere with later document processing. So using them without restraint counts as a threat of service denial ๐ซ. PostScript operators that exit the interpreter loop include, but may not be limited to, exitserver and startjob. Message-sending software should not generate PostScript that depends on exiting the interpreter loop to work. The ability to exit will probably be unavailable in secure PostScript implementations ๐. Message-receiving and -displaying software should, if possible, disable the ability to make retained changes to the PostScript environment, and eliminate the startjob and exitserver commands. If those commands can't be eliminated, the password associated with them should at least be set to a hard-to-guess value ๐.
PostScript also provides operators for setting system-wide and device-specific parameters ๐๏ธ. These settings may be kept across jobs, and they could potentially threaten the correct operation of the interpreter. The operators that set system and device parameters include, but may not be limited to, setsystemparams and setdevparams. Message-sending software should not generate PostScript that depends on those settings to work correctly. The ability to set these parameters will probably be unavailable in secure PostScript implementations ๐. Message-receiving and -displaying software should, if possible, disable the ability to change system and device parameters. If these operators can't be disabled, the password associated with them should at least be set to a hard-to-guess value ๐๏ธ.
Some PostScript implementations offer nonstandard facilities for directly loading and executing machine code ๐ค. Those facilities are obviously wide open to massive abuse ๐จ. Message-sending software should not make use of such features. Besides being totally hardware-specific, they're also likely to be unavailable in secure implementations of PostScript. Message-receiving and -displaying software should not allow such operators to be used if they exist ๐ก๏ธ.
PostScript is extensible, and lots of implementations (maybe most) add their own extensions ๐งฉ. This document doesn't deal with those extensions explicitly, since they're an unknown factor ๐ซ๏ธ. Message-sending software should not make use of nonstandard extensions, since they're likely to be missing from some implementations. Message-receiving and -displaying software should make sure that any nonstandard PostScript operators are secure and don't present any kind of threat ๐.
It's possible to write PostScript that eats up huge amounts of system resources. It's also possible to write PostScript programs that loop forever โพ๏ธ. Both types have the potential to cause damage when sent to unsuspecting recipients ๐ฑ. Message-sending software should avoid building and spreading such programs, because that's antisocial ๐ โโ๏ธ. Message-receiving and -displaying software should provide appropriate mechanisms to abort processing of a document after a reasonable amount of time has passed โฑ๏ธ. On top of that, PostScript interpreters should be limited to using only a reasonable amount of any given system resource ๐ชซ.
Finally, bugs may exist in some PostScript interpreters that could be exploited to gain unauthorized access to a recipient's system ๐ณ๏ธ. Apart from noting this possibility, there's no specific action to take to prevent it, other than the timely correction of any such bugs that get found ๐๐จ.
7.4.3. Other Application subtypes ๐ท
Lots of other subtypes of application are expected to be defined in the future ๐ญ. MIME implementations must generally treat any unrecognized subtypes as being equivalent to application/octet-stream ๐ซง.
The formal grammar for content-type header fields for application data is given by:
application-type := "application" "/" application-subtype
application-subtype := ("octet-stream" *stream-param)
/ "postscript" / extension-token
stream-param := (";" "type" "=" value)
/ (";" "padding" "=" padding)
padding := "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7"
7.5. The Image Content-Type ๐ผ๏ธ
A Content-Type of "image" means the body contains an image ๐. The subtype names the specific image format, and these names are case insensitive ๐ค. There are two initial subtypes: "jpeg" for the JPEG format (JFIF encoding), and "gif" for GIF format [GIF] ๐ฆ.
The list of image subtypes given here is neither exclusive nor exhaustive. It's expected to grow as more types get registered with IANA, as described in Appendix E ๐.
The formal grammar for the content-type header field for data of type image is given by:
image-type := "image" "/" ("gif" / "jpeg" / extension-token)
7.6. The Audio Content-Type ๐ง
Okay so a Content-Type of "audio" means the body is carrying audio data ๐ถ. There's still no consensus on an "ideal" audio format for computers (it's giving debate club ๐๏ธ), but there is a super pressing need for something everyone can interoperate with ๐ซถ.
So the first subtype, "basic", is here to meet that need ๐
. It's an absolutely minimal, lowest-common-denominator audio format, basically the bare-bones starter pack ๐. Richer formats for higher quality and/or lower bandwidth audio are expected to be defined later, in a later document โจ.
The content of audio/basic is audio encoded using 8-bit ISDN mu-law [PCM] ๐ต. When this subtype is present, a sample rate of 8000 Hz and a single channel is assumed ๐.
Here's the formal grammar for the content-type header field for data of type audio, bestie ๐:
audio-type := "audio" "/" ("basic" / extension-token)
7.7. The Video Content-Type ๐ฌ
So a Content-Type of "video" means the body holds a time-varying-picture image, maybe with color and coordinated sound ๐ฝ๏ธ. "video" is used super generically here. It isn't tied to any particular technology or format, and it doesn't rule out subtypes like compactly encoded animated drawings ๐จ. The subtype "mpeg" refers to video coded according to the MPEG standard [MPEG] ๐๏ธ.
Heads up ๐จ: even though this document really discourages mixing multiple media in a single body, it's recognized that lots of so-called "video" formats include a representation for synchronized audio. So that's explicitly permitted for subtypes of "video" ๐ซถ.
Here's the formal grammar for the content-type header field for data of type video ๐:
video-type := "video" "/" ("mpeg" / extension-token)
7.8. Experimental Content-Type Values ๐งช
A Content-Type value starting with the characters "X-" is private ๐, meant for consenting mail systems that have agreed on it between themselves ๐ค. Any format without a rigorous and public definition must be named with an "X-" prefix, and publicly specified values shall never begin with "X-" ๐ซ. (Older versions of the widely used Andrew system used the "X-BE2" name, so new systems should probably pick a different name ๐.)
Generally, using "X-" top-level types is strongly discouraged ๐
โโ๏ธ. Implementors should invent subtypes of the existing types whenever possible, bestie ๐. Inventing brand-new top-level types is meant to be mostly for new media types for email, like digital odors or holography ๐๐ฌ, not for new data formats in general. And in lots of cases, a subtype of application will be a better fit than a brand-new top-level type ๐.
8. Summary โจ
Using the MIME-Version, Content-Type, and Content-Transfer-Encoding header fields, you can include arbitrary types of data objects in RFC 822 conformant mail messages in a standardized way ๐จ. No restrictions imposed by either RFC 821 or RFC 822 are violated, and care has been taken to avoid problems caused by the extra restrictions of some Internet mail transport mechanisms (see Appendix B) ๐ง .
The "multipart" and "message" Content-Types let you mix and hierarchically structure objects of different types in a single message ๐ช. Other Content-Types give you a standardized way to tag messages or body parts as audio, image, or several other kinds of data ๐ผ๏ธ๐. A distinguished parameter syntax lets you specify data format details further, especially alternate character sets ๐ค.
Additional optional header fields provide mechanisms for certain extensions that many implementors find desirable ๐งฉ. Finally, a bunch of useful Content-Types are defined for general use by consenting user agents, notably message/partial and message/external-body ๐ฆ.
9. Security Considerations ๐
This part is really serious, so please don't skip it ๐จ.
Security issues are discussed in Section 7.4.2 and in Appendix F ๐ต๏ธ. Implementors should pay special attention to the security implications of any mail content-types that can cause remote execution of any actions in the recipient's environment ๐. In such cases, the discussion of the application/postscript content-type in Section 7.4.2 may serve as a model for considering other content-types with remote execution capabilities ๐ง.
10. Authors' Addresses ๐ฎ
For more information, the authors of this document may be contacted via Internet mail:
Nathaniel S. Borenstein
MRE 2D-296, Bellcore
445 South St.
Morristown, NJ 07962-1910
Phone: +1 201 829 4270
Fax: +1 201 829 7019
Email: nsb@bellcore.com
Ned Freed
Innosoft International, Inc.
250 West First Street
Suite 240
Claremont, CA 91711
Phone: +1 909 624 7907
Fax: +1 909 621 5319
Email: ned@innosoft.com
MIME is a result of the work of the Internet Engineering Task Force Working Group on Email Extensions ๐ฌ. The chairman of that group, Greg Vaudreuil, may be reached at:
Gregory M. Vaudreuil
Tigon Corporation
17060 Dallas Parkway
Dallas Texas, 75248
Phone: +1 214-733-2722
EMail: gvaudre@cnri.reston.va.us
11. Acknowledgements ๐ซถ
This doc is the result of a collective effort from tons of people ๐, at several IETF meetings, on the IETF-SMTP and IETF-822 mailing lists, and elsewhere. Any list of names is doomed to have egregious omissions ๐ญ, but here are some of the many contributors to this effort:
Harald Tveit Alvestrand Timo Lehtinen
Randall Atkinson John R. MacMillan
Philippe Brandon Rick McGowan
Kevin Carosso Leo Mclaughlin
Uhhyung Choi Goli Montaser-Kohsari
Cristian Constantinof Keith Moore
Mark Crispin Tom Moore
Dave Crocker Erik Naggum
Terry Crowley Mark Needleman
Walt Daniels John Noerenberg
Frank Dawson Mats Ohrman
Hitoshi Doi Julian Onions
Kevin Donnelly Michael Patton
Keith Edwards David J. Pepper
Chris Eich Blake C. Ramsdell
Johnny Eriksson Luc Rooijakkers
Craig Everhart Marshall T. Rose
Patrik Faeltstroem Jonathan Rosenberg
Erik E. Fair Jan Rynning
Roger Fajman Harri Salminen
Alain Fontaine Michael Sanderson
James M. Galvin Masahiro Sekiguchi
Philip Gladstone Mark Sherman
Thomas Gordon Keld Simonsen
Phill Gross Bob Smart
James Hamilton Peter Speck
Steve Hardcastle-Kille Henry Spencer
David Herron Einar Stefferud
Bruce Howard Michael Stein
Bill Janssen Klaus Steinberger
Olle Jaernefors Peter Svanberg
Risto Kankkunen James Thompson
Phil Karn Steve Uhler
Alan Katz Stuart Vance
Tim Kehres Erik van der Poel
Neil Katin Guido van Rossum
Kyuho Kim Peter Vanderbilt
Anders Klemets Greg Vaudreuil
John Klensin Ed Vielmetti
Valdis Kletniek Ryan Waldron
Jim Knowles Wally Wedel
Stev Knowles Sven-Ove Westberg
Bob Kummerfeld Brian Wideen
Pekka Kytolaakso John Wobus
Stellan Lagerstrom Glenn Wright
Vincent Lau Rayan Zachariassen
Donald Lindsay David Zimmerman
Marc Andreessen Bob Braden
Brian Capouch Peter Clitherow
Dave Collier-Brown John Coonrod
Stephen Crocker Jim Davis
Axel Deininger Dana S Emery
Martin Forssen Stephen Gildea
Terry Gray Mark Horton
Warner Losh Carlyn Lowery
Laurence Lundblade Charles Lynn
Larry Masinter Michael J. McInerny
Jon Postel Christer Romson
Yutaka Sato Markku Savela
Richard Alan Schafer Larry W. Virden
Rhys Weatherly Jay Weber
Dave Wecker
The authors apologize for any omissions from this list ๐, which are certainly unintentional ๐.
Appendix A -- Minimal MIME-Conformance โจ
okay bestie, the mechanisms in this doc are super open-ended ๐ฆ It is definitely not expected that every implementation will support all of the Content-Types described, or that they'll all share the same extensions ๐ But to promote interoperability, it's useful to define the concept of "MIME-conformance," which sets a certain level of implementation that allows useful interworking of messages with content that differs from US ASCII text. So in this section we spell out the requirements for that conformance ๐
A mail user agent that is MIME-conformant MUST:
- Always generate a
MIME-Version: 1.0header field ๐ - Recognize the
Content-Transfer-Encodingheader field, and decode all received data encoded with either the quoted-printable or base64 implementations. Encode any data sent that is not in seven-bit mail-ready representation using one of these transformations and include the appropriateContent-Transfer-Encodingheader field, unless the underlying transport mechanism supports non-seven-bit data, as SMTP does not ๐ฌ - Recognize and interpret the
Content-Typeheader field, and avoid showing users raw data with aContent-Typefield other than text. Be able to send at leasttext/plainmessages, with the character set specified as a parameter if it is not US-ASCII ๐ธ - Explicitly handle the following Content-Type values, to at least the following extents:
- Text:
- Recognize and display "text" mail with the character set "US-ASCII."
- Recognize other character sets at least to the extent of being able to inform the user about what character set the message uses.
- Recognize the "ISO-8859-" character sets to the extent of being able to display those characters that are common to ISO-8859- and US-ASCII, namely all characters represented by octet values 0-127.
- For unrecognized subtypes, show or offer to show the user the "raw" version of the data after conversion of the content from canonical form to local form.
- Message:
- Recognize and display at least the primary (822) encapsulation.
- Multipart:
- Recognize the primary (mixed) subtype. Display all relevant information on the message level and the body part header level, and then display or offer to display each of the body parts individually.
- Recognize the "alternative" subtype, and avoid showing the user redundant parts of multipart/alternative mail.
- Treat any unrecognized subtypes as if they were "mixed".
- Application:
- Offer the ability to remove either of the two types of Content-Transfer-Encoding defined in this document and put the resulting information in a user file.
- Upon encountering any unrecognized Content-Type, an implementation must treat it as if it had a Content-Type of "application/octet-stream" with no parameter sub-arguments. How such data are handled is up to an implementation, but likely options for handling such unrecognized data include offering the user to write it into a file (decoded from its mail transport format) or offering the user to name a program to which the decoded data should be passed as input. Unrecognized predefined types, which in a MIME-conformant mailer might still include audio, image, or video, should also be treated in this way ๐ง
A user agent that meets the above conditions is said to be MIME-conformant. The meaning of this phrase is that it is assumed to be "safe" to send virtually any kind of properly-marked data to users of such mail systems, because such systems will at least be able to treat the data as undifferentiated binary, and will not simply splash it onto the screen of unsuspecting users ๐ซถ There is another sense in which it is always "safe" to send data in a format that is MIME-conformant, which is that such data will not break or be broken by any known systems that are conformant with RFC 821 and RFC 822. User agents that are MIME-conformant have the additional guarantee that the user will not be shown data that were never intended to be viewed as text ๐ฅ
Appendix B -- General Guidelines For Sending Email Data ๐
Internet email is not a perfect, homogeneous system, bestie ๐ญ Mail may become corrupted at several stages in its travel to a final destination. Specifically, email sent throughout the Internet may travel across many networking technologies. Many networking and mail technologies do not support the full functionality possible in the SMTP transport environment, so mail traversing these systems is likely to be modified in such a way that it can be transported.
There exist many widely-deployed non-conformant MTAs in the Internet. These MTAs, speaking the SMTP protocol, alter messages on the fly to take advantage of the internal data structure of the hosts they are implemented on, or are just plain broken ๐
The following guidelines may be useful to anyone devising a data format (Content-Type) that will survive the widest range of networking technologies and known broken MTAs unscathed ๐ Note that anything encoded in the base64 encoding will satisfy these rules, but that some well-known mechanisms, notably the UNIX uuencode facility, will not. Note also that anything encoded in the Quoted-Printable encoding will survive most gateways intact, but possibly not some gateways to systems that use the EBCDIC character set.
(1) Under some circumstances the encoding used for data may change as part of normal gateway or user agent operation. In particular, conversion from base64 to quoted-printable and vice versa may be necessary. This may result in the confusion of CRLF sequences with line breaks in text bodies. As such, the persistence of CRLF as something other than a line break must not be relied on.
(2) Many systems may elect to represent and store text data using local newline conventions. Local newline conventions may not match the RFC822 CRLF convention -- systems are known that use plain CR, plain LF, CRLF, or counted records. The result is that isolated CR and LF characters are not well tolerated in general; they may be lost or converted to delimiters on some systems, and hence must not be relied on.
(3) TAB (HT) characters may be misinterpreted or may be automatically converted to variable numbers of spaces. This is unavoidable in some environments, notably those not based on the ASCII character set. Such conversion is STRONGLY DISCOURAGED, but it may occur, and mail formats must not rely on the persistence of TAB (HT) characters.
(4) Lines longer than 76 characters may be wrapped or truncated in some environments. Line wrapping and line truncation are STRONGLY DISCOURAGED, but unavoidable in some cases. Applications which require long lines must somehow differentiate between soft and hard line breaks. (A simple way to do this is to use the quoted-printable encoding.)
(5) Trailing "white space" characters (SPACE, TAB (HT)) on a line may be discarded by some transport agents, while other transport agents may pad lines with these characters so that all lines in a mail file are of equal length. The persistence of trailing white space, therefore, must not be relied on.
(6) Many mail domains use variations on the ASCII character set, or use character sets such as EBCDIC which contain most but not all of the US-ASCII characters. The correct translation of characters not in the "invariant" set cannot be depended on across character converting gateways. For example, this situation is a problem when sending uuencoded information across BITNET, an EBCDIC system. Similar problems can occur without crossing a gateway, since many Internet hosts use character sets other than ASCII internally. The definition of Printable Strings in X.400 adds further restrictions in certain special cases. In particular, the only characters that are known to be consistent across all gateways are the 73 characters that correspond to the upper and lower case letters A-Z and a-z, the 10 digits 0-9, and the following eleven special characters:
"'" (ASCII code 39)
"(" (ASCII code 40)
")" (ASCII code 41)
"+" (ASCII code 43)
"," (ASCII code 44)
"-" (ASCII code 45)
"." (ASCII code 46)
"/" (ASCII code 47)
":" (ASCII code 58)
"=" (ASCII code 61)
"?" (ASCII code 63)
A maximally portable mail representation, such as the base64 encoding, will confine itself to relatively short lines of text in which the only meaningful characters are taken from this set of 73 characters. ๐
(7) Some mail transport agents will corrupt data that includes certain literal strings. In particular, a period (".") alone on a line is known to be corrupted by some (incorrect) SMTP implementations, and a line that starts with the five characters "From " (the fifth character is a SPACE) are commonly corrupted as well. A careful composition agent can prevent these corruptions by encoding the data (e.g., in the quoted-printable encoding, "=46rom " in place of "From " at the start of a line, and "=2E" in place of "." alone on a line.
Please note that the above list is NOT a list of recommended practices for MTAs. RFC 821 MTAs are prohibited from altering the character of white space or wrapping long lines. These BAD and illegal practices are known to occur on established networks, and implementations should be robust in dealing with the bad effects they can cause. The chaos is real, bestie ๐
Appendix C -- A Complex Multipart Example ๐
okay so this is the outline of a super complex multipart message ๐ง it has five parts that get displayed one after another (serially): two intro plain text parts, an embedded multipart message, a richtext part, and a closing encapsulated text message in a non-ASCII character set ๐ the embedded multipart message has two parts that get displayed side by side (in parallel), a picture and an audio fragment โจ
MIME-Version: 1.0
From: Nathaniel Borenstein <nsb@bellcore.com>
To: Ned Freed <ned@innosoft.com>
Subject: A multipart example
Content-Type: multipart/mixed;
boundary=unique-boundary-1
This is the preamble area of a multipart message.
Mail readers that understand multipart format
should ignore this preamble.
If you are reading this text, you might want to
consider changing to a mail reader that understands
how to properly display multipart messages.
--unique-boundary-1
...Some text appears here...
[Note that the preceding blank line means
no header fields were given and this is text,
with charset US ASCII. It could have been
done with explicit typing as in the next part.]
--unique-boundary-1
Content-type: text/plain; charset=US-ASCII
This could have been part of the previous part,
but illustrates explicit versus implicit
typing of body parts.
--unique-boundary-1
Content-Type: multipart/parallel;
boundary=unique-boundary-2
--unique-boundary-2
Content-Type: audio/basic
Content-Transfer-Encoding: base64
... base64-encoded 8000 Hz single-channel
mu-law-format audio data goes here....
--unique-boundary-2
Content-Type: image/gif
Content-Transfer-Encoding: base64
... base64-encoded image data goes here....
--unique-boundary-2--
--unique-boundary-1
Content-type: text/richtext
This is <bold><italic>richtext.</italic></bold>
<smaller>as defined in RFC 1341</smaller>
<nl><nl>Isn't it
<bigger><bigger>cool?</bigger></bigger>
--unique-boundary-1
Content-Type: message/rfc822
From: (mailbox in US-ASCII)
To: (address in US-ASCII)
Subject: (subject in US-ASCII)
Content-Type: Text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: Quoted-printable
... Additional text in ISO-8859-1 goes here ...
--unique-boundary-1--
Appendix D -- Collected Grammar ๐
this appendix is the full BNF grammar for every bit of syntax this document specifies ๐ but heads up, it's not complete on its own! it leans on a bunch of stuff defined in RFC 822, and instead of copying those definitions over (and risking them drifting apart), the document just sends you to RFC 822 for the rest ๐ so whenever a term isn't defined here, go check the RFC 822 definition
application-subtype := ("octet-stream" *stream-param)
/ "postscript" / extension-token
application-type := "application" "/" application-subtype
attribute := token ; case-insensitive
atype := "ftp" / "anon-ftp" / "tftp" / "local-file"
/ "afs" / "mail-server" / extension-token
; Case-insensitive
audio-type := "audio" "/" ("basic" / extension-token)
body-part := <"message" as defined in RFC 822,
with all header fields optional, and with the
specified delimiter not occurring anywhere in
the message body, either on a line by itself
or as a substring anywhere.>
๐ NOTE, bestie: in some transport enclaves, the RFC 822 rules (like the one that limits bodies to printable ASCII characters) might not be enforced. Those domains can look a lot like standard Internet mail transport as described in RFC821 and assumed by RFC822, just without certain restrictions. Loosening those rules should be treated as locally widening what counts as a body, for example allowing octets outside the ASCII range, as long as the transport supports it and it's properly documented in the Content-Transfer-Encoding header field. But no matter what, headers (both message headers and body-part headers) are never allowed to contain anything other than ASCII characters ๐ซ
boundary := 0*69<bchars> bcharsnospace
bchars := bcharsnospace / " "
bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" / "_"
/ "," / "-" / "." / "/" / ":" / "=" / "?"
charset := "us-ascii" / "iso-8859-1" / "iso-8859-2"/ "iso-8859-3"
/ "iso-8859-4" / "iso-8859-5" / "iso-8859-6" / "iso-8859-7"
/ "iso-8859-8" / "iso-8859-9" / extension-token
; case insensitive
close-delimiter := "--" boundary "--" CRLF;Again,no space by "--",
content := "Content-Type" ":" type "/" subtype *(";" parameter)
; case-insensitive matching of type and subtype
delimiter := "--" boundary CRLF ;taken from Content-Type field.
; There must be no space
; between "--" and boundary.
description := "Content-Description" ":" *text
discard-text := *(*text CRLF)
encapsulation := delimiter body-part CRLF
encoding := "Content-Transfer-Encoding" ":" mechanism
epilogue := discard-text ; to be ignored upon receipt.
extension-token := x-token / iana-token
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
/ (";" "name" "=" value)
/ (";" "site" "=" value)
/ (";" "dir" "=" value)
/ (";" "mode" "=" value)
/ (";" "server" "=" value)
/ (";" "subject" "=" value)
;access-type required; others required based on access-type
iana-token := <a publicly-defined extension token,
registered with IANA, as specified in
appendix E>
id := "Content-ID" ":" msg-id
image-type := "image" "/" ("gif" / "jpeg" / extension-token)
mechanism := "7bit" ; case-insensitive
/ "quoted-printable"
/ "base64"
/ "8bit"
/ "binary"
/ x-token
message-subtype := "rfc822"
/ "partial" 2#3partial-param
/ "external-body" 1*external-param
/ extension-token
message-type := "message" "/" message-subtype
multipart-body :=preamble 1*encapsulation close-delimiter epilogue
multipart-subtype := "mixed" / "parallel" / "digest"
/ "alternative" / extension-token
multipart-type := "multipart" "/" multipart-subtype
";" "boundary" "=" boundary
octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F")
; octet must be used for characters > 127, =, SPACE, or
TAB,
; and is recommended for any characters not listed in
; Appendix B as "mail-safe".
padding := "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7"
parameter := attribute "=" value
partial-param := (";" "id" "=" value)
/ (";" "number" "=" 1*DIGIT)
/ (";" "total" "=" 1*DIGIT)
; id & number required;total required for last part
preamble := discard-text ; to be ignored upon receipt.
ptext := octet / <any ASCII character except "=", SPACE, or TAB>
; characters not listed as "mail-safe" in Appendix B
; are also not recommended.
quoted-printable := ([*(ptext / SPACE / TAB) ptext] ["="] CRLF)
; Maximum line length of 76 characters excluding CRLF
stream-param := (";" "type" "=" value)
/ (";" "padding" "=" padding)
subtype := token ; case-insensitive
text-subtype := "plain" / extension-token
text-type := "text" "/" text-subtype [";" "charset" "=" charset]
token := 1*<any (ASCII) CHAR except SPACE, CTLs, or tspecials>
tspecials := "(" / ")" / "<" / ">" / "@"
/ "," / ";" / ":" / "\" / <">
/ "/" / "[" / "]" / "?" / "="
; Must be in quoted-string,
; to use within parameter values
type := "application" / "audio" ; case-insensitive
/ "image" / "message"
/ "multipart" / "text"
/ "video" / extension-token
; All values case-insensitive
value := token / quoted-string
version := "MIME-Version" ":" 1*DIGIT "." 1*DIGIT
video-type := "video" "/" ("mpeg" / extension-token)
x-token := <The two characters "X-" or "x-" followed, with no
intervening white space, by any token>
Appendix E -- IANA Registration Procedures ๐ฆ
okay so MIME was built to be extensible on purpose ๐ we fully expect the list of content-type/subtype pairs (and their parameters) to keep growing over time โจ other MIME bits, like character set names, access-type parameters for the message/external-body type, and maybe even Content-Transfer-Encoding values, will also get new values as time goes on ๐ to keep all of that orderly, well-specified, and public, MIME sets up a registration process that uses the Internet Assigned Numbers Authority (IANA) as the central registry ๐
in general, parameters in the content-type header field are there to carry extra info for different content types, and how they get used gets defined when the content-type and subtype are defined ๐ new parameters should not be defined as a way to add new functionality, bestie ๐
to make registering stuff simpler and more standardized, this appendix gives you templates for registering new values with IANA ๐จ each one is an email message template that the registering party fills in ๐
E.1. Registration of New Content-type/subtype Values โจ
so MIME is generally expected to get extended through subtypes ๐ if a brand new fundamental top-level type is needed, its specification must be published as an RFC (or submitted in a form that's ready to become an RFC), and it has to go through the Internet standards process ๐ฅ
To: IANA@isi.edu
Subject: Registration of new MIME
content-type/subtype
MIME type name:
(If the above is not an existing top-level MIME type,
please explain why an existing type cannot be used.)
MIME subtype name:
Required parameters:
Optional parameters:
Encoding considerations:
Security considerations:
Published specification:
(The published specification must be an Internet RFC or
RFC-to-be if a new top-level type is being defined, and
must be a publicly available specification in any
case.)
Person & email address to contact for further information:
E.2. Registration of New Access-type Values for Message/external-body ๐ธ
To: IANA@isi.edu
Subject: Registration of new MIME Access-type for
Message/external-body content-type
MIME access-type name:
Required parameters:
Optional parameters:
Published specification:
(The published specification must be an Internet RFC or
RFC-to-be.)
Person & email address to contact for further information:
Appendix F -- Summary of the Seven Content-types โจ
okay bestie, this appendix is basically a cheat sheet ๐ All seven content-types get recapped in one place so you don't have to flip around. Let's go ๐
Content-type: text ๐ฆ
Subtypes defined by this document: plain
Important Parameters: charset
Encoding notes: quoted-printable generally preferred if an encoding is needed and the character set is mostly an ASCII superset ๐ซถ
Security considerations: okay this part is seriously important ๐จ Rich text formats like TeX and Troff often have built-in ways to run arbitrary commands or do file system operations, so they should not be used automatically unless those security problems have been dealt with. Even plain text can carry control characters that can be used to exploit the abilities of "intelligent" terminals and cause security violations. User interfaces built to run on those terminals should be aware of this and try to prevent these problems ๐
Content-type: multipart ๐ธ
Subtypes defined by this document: mixed, alternative, digest, parallel
Important Parameters: boundary
Encoding notes: no content-transfer-encoding is permitted, so don't even try ๐
Content-type: message ๐
Subtypes defined by this document: rfc822, partial, external-body
Important Parameters: id, number, total, access-type, expiration, size, permission, name, site, directory, mode, server, subject
Encoding notes: no content-transfer-encoding is permitted either ๐
โโ๏ธ Specifically, only 7bit is permitted for message/partial or message/external-body, and only 7bit, 8bit, or binary are permitted for other subtypes of message โจ
Content-type: application ๐ง
Subtypes defined by this document: octet-stream, postscript
Important Parameters: type, padding
Deprecated Parameters: name and conversions were defined in RFC 1341. Lowkey retired vibes ๐ฅ
Encoding notes: base64 preferred for unreadable subtypes ๐
Security considerations: bestie, this one is dramatic ๐ญ This type is meant for sending data that will be interpreted by programs already installed on the receiving machine. If it gets used to send executable binary programs, or programs in general-purpose interpreted languages like LISP programs or shell scripts, severe security problems could result ๐ฅ Authors of mail-reading agents are cautioned not to give their systems the power to execute mail-based application data without carefully thinking through the security implications. Yes, it is totally possible to define safe application formats and even safe interpreters for unsafe formats ๐ซ But each interpreter should be evaluated separately for possible security problems, no exceptions ๐ก๏ธ
Content-type: image ๐ผ๏ธ
Subtypes defined by this document: jpeg, gif
Important Parameters: none
Encoding notes: base64 generally preferred ๐
Content-type: audio ๐ง
Subtypes defined by this document: basic
Important Parameters: none
Encoding notes: base64 generally preferred ๐ถ
Content-type: video ๐ฌ
Subtypes defined by this document: mpeg
Important Parameters: none
Encoding notes: base64 generally preferred ๐ฟ
Appendix G -- Canonical Encoding Model ๐ง
Okay so there was some confusion in earlier drafts of this memo ๐ตโ๐ซ People weren't sure when email data was supposed to get converted to canonical form and encoded, and how that would change the way CRLFs get handled. Like, newlines look totally different from system to system! So this appendix gives a canonical model for encoding to clear it all up ๐
The process of composing a MIME entity can be modeled as a bunch of steps. These steps are roughly similar to the ones in RFC 1421, and they're done for each 'innermost level' body ๐ซถ
Step 1. Creation of local form ๐ก
The body to be transmitted gets created in the system's native format. The native character set is used, and where it makes sense, local end of line conventions are used too. The body could be a UNIX-style text file, a Sun raster image, a VMS indexed file, audio data in a system-dependent format that only lives in memory, or literally anything else that matches the local way of representing some kind of information โจ Basically, the data gets created in the "native" form specified by the type/subtype info ๐
Step 2. Conversion to canonical form ๐
The entire body gets converted to a universal canonical form, including "out-of-band" info like record lengths and maybe file attribute info ๐ง The specific content type and its attributes decide what the canonical form looks like. Converting might involve character set conversion, transforming audio data, compression, or other stuff specific to each content type ๐ต If character set conversion is involved though, you have to understand the semantics of the content-type first, because it can have big implications for the conversion. For example, syntactically meaningful characters in a text subtype other than plain need extra care ๐
Here's an example: for text/plain data, the text has to be converted to a supported character set, and lines have to be delimited with CRLF delimiters per RFC822 ๐ The line length restriction that RFC822 implies goes away if the next step uses quoted-printable or base64 encoding, so it's not a big deal anymore ๐
Step 3. Apply transfer encoding ๐
A Content-Transfer-Encoding that fits this body gets applied ๐ There's no fixed relationship between content type and transfer encoding, so bestie, don't assume anything ๐ In particular, it might make sense to pick base64 or quoted-printable based on character frequency counts that are specific to one particular instance of a body ๐
Step 4. Insertion into entity ๐ช
The encoded object gets inserted into a MIME entity with the right headers โจ Then the entity goes into the body of a higher-level entity (a message or multipart) if needed ๐ซง
It is vital to note that these steps are only a model. They are specifically not a blueprint for how an actual system would be built ๐ซ The model doesn't account for two common designs:
- In lots of cases, the conversion to canonical form before encoding gets folded into the encoder itself, since it understands local formats directly. For example, the local newline convention for text bodies might be carried through to the encoder along with knowledge of what that format is ๐งฉ
- The output of the encoders may have to go through one or more additional steps before it gets transmitted as a message. Because of that, the encoder's output might not match the formats specified by RFC822. In particular, once again, it may make sense for the converter's output to use local newline conventions instead of the standard RFC822 CRLF delimiters ๐
Other implementation variations are totally conceivable too ๐ The vital part is this: no matter what optimizations, collapsed required steps, or extra processing get added, the resulting messages must still be consistent with the ones this model produces. For example, a message with these header fields:
Content-type: text/foo; charset=bar
Content-Transfer-Encoding: base64
must first be represented in the text/foo form, then (if necessary) represented in the "bar" character set, and finally transformed via the base64 algorithm into a mail-safe form ๐
Appendix H -- Changes from RFC 1341 ๐
This document is a pretty minor revision of RFC 1341 ๐ฅน For anyone who already knows RFC 1341, the technical changes are summarized in this appendix. Here's the tea โ
- The definition of "tspecials" no longer includes ".".
- The Content-ID field is now mandatory for message/external-body parts.
- The text/richtext type (including the old Section 7.1.3 and Appendix D) has been moved to a separate document ๐ฆ
- The rules on header merging for message/partial data have been changed to treat the Encrypted and MIME-Version headers as special cases.
- The definition of the external-body access-type parameter has been changed so that it can only indicate a single access method, which was honestly all that made sense ๐
- There is a new "Subject" parameter for message/external-body, access-type mail-server, so MIME-based use of mail servers that rely on Subject field information can work ๐ฌ
- The "conversions" parameter for application/octet-stream has been removed ๐
- Section 7.4.1 now deprecates the use of the "name" parameter for application/octet-stream, since a Content-Disposition header will supersede it in the future ๐ซก
- The formal grammar for multipart bodies has changed so that a CRLF is no longer required before the first boundary line โจ
- MIME entities of type "message/partial" and "message/external-body" are now required to use only the "7bit" transfer-encoding. Specifically, "binary" and "8bit" are not permitted ๐ซ
- The "application/oda" content-type has been removed ๐๏ธ
- A note has been added to the end of section 7.2.3, explaining the semantics of Content-ID in a multipart/alternative MIME entity ๐งท
- The formal syntax for the "MIME-Version" field has been tightened, but in a way that is completely compatible with the only version number defined in RFC 1341 ๐งธ
- In Section 7.3.1, the definition of message/rfc822 has been relaxed regarding mandatory fields ๐ท
All other changes from RFC 1341 were editorial and don't affect the technical content of MIME ๐ Considerable formal grammar has been added, but that just reflects the prose specification that was already in place. So it's giving tidy, not new ๐
References ๐โจ
okay bestie, this is the reading list ๐ every source the spec cites, so you can go deeper whenever you're feeling brave ๐ง
- [US-ASCII] Coded Character Set--7-Bit American Standard Code for Information Interchange, ANSI X3.4-1986.
- [ATK] Borenstein, Nathaniel S., Multimedia Applications Development with the Andrew Toolkit, Prentice-Hall, 1990.
- [GIF] Graphics Interchange Format (Version 89a), Compuserve, Inc., Columbus, Ohio, 1990.
- [ISO-2022] International Standard--Information Processing--ISO 7-bit and 8-bit coded character sets--Code extension techniques, ISO 2022:1986.
- [ISO-8859] Information Processing -- 8-bit Single-Byte Coded Graphic Character Sets -- Part 1: Latin Alphabet No. 1, ISO 8859-1:1987. Part 2: Latin alphabet No. 2, ISO 8859-2, 1987. Part 3: Latin alphabet No. 3, ISO 8859-3, 1988. Part 4: Latin alphabet No. 4, ISO 8859-4, 1988. Part 5: Latin/Cyrillic alphabet, ISO 8859-5, 1988. Part 6: Latin/Arabic alphabet, ISO 8859-6, 1987. Part 7: Latin/Greek alphabet, ISO 8859-7, 1987. Part 8: Latin/Hebrew alphabet, ISO 8859-8, 1988. Part 9: Latin alphabet No. 5, ISO 8859-9, 1990. ๐
- [ISO-646] International Standard--Information Processing--ISO 7-bit coded character set for information interchange, ISO 646:1983.
- [MPEG] Video Coding Draft Standard ISO 11172 CD, ISO IEC/TJC1/SC2/WG11 (Motion Picture Experts Group), May, 1991.
- [PCM] CCITT, Fascicle III.4 - Recommendation G.711, Geneva, 1972, "Pulse Code Modulation (PCM) of Voice Frequencies".
- [POSTSCRIPT] Adobe Systems, Inc., PostScript Language Reference Manual, Addison-Wesley, 1985.
- [POSTSCRIPT2] Adobe Systems, Inc., PostScript Language Reference Manual, Addison-Wesley, Second Edition, 1990.
- [X400] Schicker, Pietro, "Message Handling Systems, X.400", Message Handling Systems and Distributed Applications, E. Stefferud, O-j. Jacobsen, and P. Schicker, eds., North-Holland, 1989, pp. 3-41.
- [RFC-783] Sollins, K., "TFTP Protocol (revision 2)", RFC 783, MIT, June 1981.
- [RFC-821] Postel, J., "Simple Mail Transfer Protocol", STD 10, RFC 821, USC/Information Sciences Institute, August 1982.
- [RFC-822] Crocker, D., "Standard for the Format of ARPA Internet Text Messages", STD 11, RFC 822, UDEL, August 1982.
- [RFC-934] Rose, M., and E. Stefferud, "Proposed Standard for Message Encapsulation", RFC 934, Delaware and NMA, January 1985.
- [RFC-959] Postel, J. and J. Reynolds, "File Transfer Protocol", STD 9, RFC 959, USC/Information Sciences Institute, October 1985.
- [RFC-1049] Sirbu, M., "Content-Type Header Field for Internet Messages", STD 11, RFC 1049, CMU, March 1988.
- [RFC-1421] Linn, J., "Privacy Enhancement for Internet Electronic Mail: Part I - Message Encryption and Authentication Procedures", RFC 1421, IAB IRTF PSRG, IETF PEM WG, February 1993.
- [RFC-1154] Robinson, D. and R. Ullmann, "Encoding Header Field for Internet Messages", RFC 1154, Prime Computer, Inc., April 1990.
- [RFC-1341] Borenstein, N., and N. Freed, "MIME (Multipurpose Internet Mail Extensions): Mechanisms for Specifying and Describing the Format of Internet Message Bodies", RFC 1341, Bellcore, Innosoft, June 1992.
- [RFC-1342] Moore, K., "Representation of Non-Ascii Text in Internet Message Headers", RFC 1342, University of Tennessee, June 1992.
- [RFC-1343] Borenstein, N., "A User Agent Configuration Mechanism for Multimedia Mail Format Information", RFC 1343, Bellcore, June 1992.
- [RFC-1344] Borenstein, N., "Implications of MIME for Internet Mail Gateways", RFC 1344, Bellcore, June 1992.
- [RFC-1345] Simonsen, K., "Character Mnemonics & Character Sets", RFC 1345, Rationel Almen Planlaegning, June 1992.
- [RFC-1426] Klensin, J., (WG Chair), Freed, N., (Editor), Rose, M., Stefferud, E., and D. Crocker, "SMTP Service Extension for 8bit-MIME transport", RFC 1426, United Nations Universit, Innosoft, Dover Beach Consulting, Inc., Network Management Associates, Inc., The Branch Office, February 1993.
- [RFC-1522] Moore, K., "Representation of Non-Ascii Text in Internet Message Headers" RFC 1522, University of Tennessee, September 1993.
- [RFC-1340] Reynolds, J., and J. Postel, "Assigned Numbers", STD 2, RFC 1340, USC/Information Sciences Institute, July 1992.
๐ฆ where this page comes from
- ietf: rfc1521 1993-09
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms