How Multipurpose Internet Mail Extensions (MIME) Works

MIME makes it easy to send file attachments with emails

Fiber optic world

Henrik5000 / Getty Images

MIME stands for Multipurpose Internet Mail Extensions. MIME extends the original capabilities of internet email in a useful, content-rich way.

Email messages have been defined by RFC 822 (and later RFC 2822) since 1982, and they will probably continue to obey this standard for a long time to come. MIME extends RFC 822 standards beyond what was envisioned nearly 40 years ago.

Nothing but Plain Text

RFC 822 suffers from a number of shortcomings. Most notably, messages conforming to that standard must not contain anything but plain ASCII text.

To send files like pictures, text processor documents or programs, you must convert them to plain text first and then send the result of the conversion in the body of an email message. The recipient has to extract the text from the message and convert it to the binary file format again. This is a cumbersome process, and before MIME it all had to be done by hand.

MIME corrects this problem attached to RFC 822, and it makes it possible to use international characters in email messages, too. With the RFC 822 limitation to plain (English) text, this capability had not been possible before.

The Lack of Structure

In addition to being limited to ASCII characters, RFC 822 does not identify the structure of a message or the format of the data. Because with plain-text data, everything comes in one chunk, a detailed structural topography wasn't necessary when the original standard went into effect.

MIME, in contrast, lets you send several pieces of different units data in one message (say, a picture and a Word document), and it tells the recipient's email client what format the data is in so they can make smart choices displaying the message.

When you get a picture, you do no longer have to figure out that it can be viewed with an image viewer. Your email client either displays the image itself or start a program on your computer that can.

Building on and Extending RFC 822

Now how does the MIME magic work? Basically, it employs the cumbersome process of sending arbitrary data in plain text. The MIME message standard does not replace the standard laid down in RFC 822 but extends it. MIME messages cannot contain anything but ASCII text, either.

This means that all email data must still be encoded in plain text before the message is sent, and it must be decoded to its original format on the receiving end again. The early email users had to do that manually. MIME does it for us comfortably and seamlessly, usually through a smart process called Base64 encoding.

Life as a MIME Email Message

When you compose a message in an email program capable of MIME, the program does roughly the following:

  • If the message is in plain ASCII text only, it leaves it alone and only tells the recipient's email client to expect nothing but plain text.
  • If the message contains one or more attachments and a body with HTML formatting, each part is looked at and treated separately.

First, the format of the data is determined. This step is necessary to tell the recipient's email client what to do with the data and to ensure proper encoding so nothing is lost during transfer.

Then the data is encoded if it is in a format other than plain ASCII text. In the encoding process, the data is converted to the plain text suitable for RFC 822 messages.

Finally, the encoded data is inserted in the message, and the recipient's email client is informed what kinds of data to expect: Are there attachments? How are they encoded? What format was the original file in?

On the recipient's end, the process is reversed. First, the email client reads the information that was added by the sender's email client: Do I have to look for attachments? How do I decode them? How do I handle the resulting files? Then, each part of the message is extracted and decoded if necessary. Finally, the email client displays the resulting parts to the user. The plain-text body is shown inline in the email client together with the image attachment. The program also attached to the message is displayed with an attachment icon, and the recipient can decide what to do with it. She can save it somewhere on her disk, or start it directly from the email program.