All mime parts can have certain headers. The following paragraphs will
discuss headers and Mime parts.
A header consists of a Name: Value pair, and can also have parameters. The Name and Value are always separated by a colon. If the header contains any parameters, a semi-colon is placed immediately after the value, and the parameters are added to the header. Each additional parameter is also separated by a semi-colon.
The Name must also start at the beginning of a new line, and cannot have
any white space before it. If a line starts with any white space, that line
is said to be 'folded' and is actually part of the header above it.
Header Syntax:
Name “:" value “;” parameter
In the following example, the header name is actually 'Content-Type',
the value is 'image/gif'. The parameter is 'name=”pic2.gif”'.
Example
Content-Type: image/gif;
name="pic2.gif"
Notice the white-space before ‘name’. This makes the parameter actually part
of the preceding header.
There are a few common, standard headers that are part of MIME messages.
Some of them are discussed below.
MIME-Version
This header is used to identify the format of the Mime message. It almost always has the value of 1.0.
Example:
MIME-Version: 1.0
Content-Type
This header describes the data contained in the Mime part. Some of the more common content-type headers are listed below.
Content-Type: text/html
Content-Type: text/plain
Content-Type: image/gif
Content-Type: image/jpg
The content-type header can also have a charset parameter. Thus, it is not uncommon to see a header such as:
Content-Type: text/html;
charset="iso-8859-1"
This tells the email reader any following HTML text has a ISO-8859-1 character set.
Content-Transfer-Encoding
Generally speaking, email must be transmitted using ONLY ASCII characters. Binary data, and\or languages that use characters above ASCII value 127, or below ASCII value 32, must be encoded. The Content-Transfer-Encoding header, describes the encoding scheme used to convert non-ASCII data to ASCII characters.
The most common encoding schemes include:
1. 7bit
2. base64
3. Quoted-Printable
1. 7bit Encoding
The 7bit encoding is used for any ASCII characters with a value of 128 or less. Basically no encoding is used. If the Content-Transfer-Encoding header is not supplied, the MIME part is assumed to be 7bit encoded.
2. base64 Encoding
base64 encoding is used to encode binary data. It converts groups of three 8-bit bytes into groups of four printable ASCII characters. The attachments found in this email, are base64 encoded.
3. Quoted-Printable
Unlike the group encoding techniques used by base64 encoding, the quoted-printable format encodes each non-ASCII character into a ‘=’, followed by its hexadecimal equivalent number. For example, a carriage-return sequence (ASCII values 13 and 10) are encoded into =0D=0A. The disadvantage of this encoding is that 3 bytes of characters are now required for each 1 byte of non-ASCII data. This greatly increases the size of the message.
Content-ID
The Content-ID header uniquely identifies a Mime part. The most common use of Content-ID’s are to reference embedded images. For example, if the following <img src=”cid:mylogo”> is found in the HTML body part. The mail reader will reference the MIME part with the header
Content-ID: <mylogo>
Content-Disposition
The content-disposition header generally marks the body part as an attachment. Attachments are typically meant to be opened outside of the email client, unlike client-ID’s, which are generally viewed ‘inside’ of the email client (as embedded images).