4.16.1. The MIME protocol

Multipurpose Internet Mail Extensions (MIME) is a complex representation of multiple type of message bodies, and refers to an official Internet standard that defines how messages must be formatted. It makes possible for different types of e-mail systems to exchange messages successfully. MIME is a flexible format which allows to include different type of messages in a single e-mail message. It redefines message format to allow:

  • text messages in different character sets;

  • extensible set of non-text format messages;

  • multiple message types in one message body;

  • text header information.

The content of the message is shown by the MIME header, which indicates the type and number of parts the message contains. The header also contains encoding system and version information. MIME supports the following body-types:

Body-typeDescription
text The primary type of MIME content. The main subtype is plain.
multipart The message contains different types of data.
message Indicates an encapsulated text message.
image Indicates that the message contains image file.
audio Indicates that the message contains audio data.
video Indicates that the message contains video data.

Table 4.44. MIME body-types

To make sure message contents arrive without corruption, non-text messages must be encoded to printable ASCII characters. Older UNIX systems use uuencode/uudecode transformation. MIME encoding provides base64 to encode any attachment as text.

MIME indicates the parameters of the message in the header field, which can be the following:

MIME headerDescription
MIME-Version Indicates the exact version of the MIME message.
Content-Type Indicates the type of the data contained in the body. The default content type is 'text/plain; charset=us-ascii'.
Content-Transfer-Encoding Indicates the encoding used in the message part. It is also possible to create private transfer encoding, which can be indicated by X-My-Private-Transfer-Encoding.
Content-ID Unique identifier of the MIME object.
Content-Description Extra comments added to the message by the user.
Additional MIME Header Fields Extra fields to be used by the developers in the future.

Table 4.45. MIME headers

Note

MIME headers do not guarantee that the message really contains the type of content indicated in the header.

Example 4.29. Example mail header containing MIME message

A simple e-mail message containing text message.

From: Sender User <sender@balasys.hu>
To: Receiver User <receiver@balasys.com>
Message-Id: <asdfghjkl@balasys.internal.server>
Content-Type: text/plain
Mime-Version: 1.0
Date: Thu, 01 Jul 2004 11:34:30 +0200
Content-Transfer-Encoding: 7bit
Example 4.30. Example PNG format picture attachment

A message containing an image attachment in base64 encoding.

Mime-Version: 1.0
Content-Type: image/jpeg; name="image.png"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="image.png"
Example 4.31. Example multipart message

A multipart type message containing a simple text message with a postscript attachment.

This is a multi-part message in MIME format.
--------------080709090505030904090905
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

us-ascii message comes here...

--------------080709090505030904090905
Content-Type: application/postscript; name="zorp-pro-reference-guide-3.0.ps"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="zorp-pro-reference-guide-3.0.ps"

base64 message comes here...