The Multipart Content-Type

<< Click to Display Table of Contents >>

Navigation:  MIME >

The Multipart Content-Type

Previous pageReturn to chapter overviewNext page

Through the use of the multipart content type,  MIME allows mail messages to have parts arranged in a tree structure where the leaf nodes are any non-multipart content type and the non-leaf nodes are any of a variety of multipart types. This supports any number of subtypes, such as simple text messages (text/plain), text with attachments, and replies with original attached; it also supports alternative content, such as a message in both plain text and HTML, images (image/jpeg), audio (audio/mp3), video (video/mp4), applications (application/msword); and so on.

 

A MIME multipart message contains a boundary in the Content-Type header. This boundary must not occur in any of the parts and is usually a randomly generated string; it is up to the client to choose a boundary string that doesn't clash with the body text. It is placed at the beginning, between message parts, and at the end of the Multipart message. The last boundary is always followed by two hyphens identifying it as such. Each part bookmarked by the boundary contains its own header and body. An example:

 

 MIME-Version: 1.0

 Content-Type: multipart/mixed; boundary=frontier

 

 This is a message with multiple parts in MIME format.

 --frontier

 Content-Type: text/plain

 

 This is the body of the message.

 --frontier

 Content-Type: application/octet-stream

 Content-Transfer-Encoding: base64

 

 PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg

 Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg==

 --frontier--