1. Computing
Send to a Friend via Email

Discuss in my forum

How MIME Works

MIME makes it easy to send file attachments with emails. Here's how it works.

By

MIME stands for "Multipurpose Internet Mail Extensions". It sound both complicated and meaningless, but MIME extends the original capabilities of internet email in an exciting 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.

Nothing But Text, Plain Text

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

In order to send files (like pictures, text processor documents or programs), one has to 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 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. Since it is clear that you always get one junk of plain text data, this was not necessary when the standard was defined.

MIME, in contrast, lets you send multiple pieces of different 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 described above. 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 via 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 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 in line in the email client together with the image attachment. The program also attached to the message is displayed with an attachment icon, and the user can decide what to do with it. She can save it somewhere on her disk, or start it directly from the email program.

Related Video
Create Email Aliases and Forwarding Addresses in Gmail

©2014 About.com. All rights reserved.