Chilkat Email Components Home

Content-Type

Back

Indicates the type and subtype of the message content, for example The combination of type and subtype is generally called a MIME type, although in modern applications, Internet media type is the favored term, indicating its applicability outside of MIME messages. A large number of file formats have registered MIME types. Any text type has an additional charset parameter that can be included to indicate the character encoding. A very large number of character encodings have registered MIME charset names.

Through the use of the multipart type, MIME allows 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 mechanism supports:

  • simple text messages using text/plain (the default value for "Content-type:")
  • text plus attachments (multipart/mixed with a text/plain part and other non-text parts). A MIME message including an attached file generally indicates the file's original name with the "Content-disposition:" header, so the type of file is indicated both by the MIME content-type and the (usually OS-specific) filename extension
  • reply with original attached (multipart/mixed with a text/plain part and the original message as a message/rfc822 part)
  • alternative content, such as a message sent in both plain text and another format such as HTML (multipart/alternative with the same content in text/plain and text/html forms)
  • many other message constructs

    A MIME multipart message contains a boundary in the "Content-type:" header; this boundary, which must not occur in any of the parts, is placed between the parts, and at the beginning and end of the body of the message.

    Each part consists of its own content header (zero or more Content- header fields) and a body. Multipart content can be nested. A multipart never has a global charset or Content-Transfer-Encoding, these details are determined by the Content- header fields of the individual parts. There are several different types of multipart messages:

    Notes:

    • Before the first boundary is an area thats ignored by MIME compliant clients. This area is generally used to put a message to users of old non-MIME clients.
    • It is up to the sending mail client to choose a boundary string that doesn't clash with the body text. Typically this is done by inserting a large random string.

    Mixed

    Multipart/mixed is used for sending files with different "Content-type" headers inline (or as attachments). If sending pictures or other easily readable files, most mail clients will display them inline (unless otherwise specified with the "Content-disposition" header). Otherwise it will offer them as attachments.

    Digest

    Multipart/mixed and multipart/digest must be supported for minimal MIME conformance as specified in RFC 2049. The default content type for a mixed part is text/plain; for a digest, it's message/rfc822. Multipart/digest is a simple way to forward one or more messages.

    Alternative

    The multipart/alternative message is supposed to have the same (or similar) content in each part has a different "Content-type" header. The formats are ordered from worst representation to best representation (this order was chosen so that plain text would end up first, making life easier for users of non-mime clients). Mail clients are supposed to choose the last part that they are capable of displaying, though some may not follow this and give a particular content type priority. Typically this type is used with a text/plain part first to support older clients followed by a text/html part to provide a formatted message for modern clients.

    Spammers took advantage of this and filled a text/plain part of a multipart/alternative message with words that make it sound like a legitimate e-mail. This was particularly good at fooling Bayesian filtering spam filters.

    Related

    A multipart/related has as its first part its main content. All following items should have the mime-header "Content ID:" followed by some unique title. Often times a URL is used as the Content ID. The main part can then reference those items as inline. A common technique is to have the main part an HTML document, and use image tags to reference images stored in the latter parts.

    Report

    Multipart/report is a message type that contains data formatted for a mail server to read. It is split between a text/plain (or some other content/type easily readable) and a message/delivery-status, which contains the data formatted for the mail server to read.

    Signed

    A multipart/signed message has two parts, a body part and a signature part. The whole of the body part, including mime headers, is used to create the signature part. Many signature types are possible, like application/pgp-signature and application/x-pkcs7-signature.

    Encrypted

    A multipart/encrypted message has two parts. The first part has control information that is needed to decrypt the application/octet-stream second part.

  • Example:
    
    Content-type: multipart/alternative; 
       boundary="Boundary_(ID_Kgm8Rp+2f6GLTl0Fb+OQLA)"