ACCC Home Page ACADEMIC COMPUTING and COMMUNICATIONS CENTER
Accounts / Passwords Email Labs / Classrooms Telecom Network Security Software Computing and Network Services Education / Teaching Getting Help
 
The ADN Connection, September/October 1996 The A3C Connection
Sept/Oct 1996 Contents Public Labs Require Passwords Making Email Talk with MIME A Brief Email History File Transfer is More Complicated If...
Getting Ready for Fall Semester Netscape's Mail and News Setup borg Update About the ADN Connection  

Making Email Talk with MIME

 
Tech Tips
Many Everyone
 
   
 
     
Fancying Up Your Email
 

Would you like your email to look as nice as Web pages do? Would you like send a picture in a note? Or send a WordPerfect file to a colleague in Europe, perhaps, or submit a paper for publication electronically? World Wide Web servers do things like this all the time. Why not email?

You can do all these things in email. In fact, the protocols used by Web servers and browsers to exchange "rich text" files over the Internet were developed to perform the same tasks for electronic mail: Multipurpose Internet Mail Extensions, or MIME (pronounced as the word mime).

Want to use MIME? Pine on UNIX understands it. Eudora does too, so if you've installed the ADN Network Services Kit on your personal computer, then you're set. Also newer versions of most WWW browsers, including Netscape, allow you to send email notes with MIME attachments.

Alas, neither mail nor note on CMS are MIME-aware. (Nor is that likely to change. Another hint, perhaps?)

Back to Contents

 
     
What MIME Does
  When Internet email was originally defined, its purpose was to enable the exchange of short messages that would be read by people. So its original definition was simple: a short "header" consisting of a few human-readable header lines that say where the message is coming from and where it's going to; a blank line to separate the header from the body; and a single (non-structured) message body containing only human-readable text.

Over the years, it became clear that people wanted to do more with email than its designers originally envisioned. MIME was designed to deal with these needs. The specific goals taken on by the MIME development team were:

  • Develop a clearly defined, foolproof way to encode machine-readable ("binary") data for inclusion in email.
  • Design a structure for email bodies, allowing them to have multiple parts, including binary or application-specific files and text in character sets other than 7-bit US ASCII. The structure must include enough information that the email systems receiving the email -- MIME standards call these "user agents" -- will know what to do with each part.
  • Make MIME extendible so that it can support the "application-specific" files of tomorrow's applications without requiring changes in the standard.
  • Do all of this without breaking any existing email systems or gateways.

And that's exactly what MIME does.

See A Brief Email History (or why MIME does what it does) for a bit of background information on how email and MIME are defined and what these goals mean. 

Back to Contents

 
     
How MIME Does It
  The MIME designers took advantage of a small but crucial feature in the original definition of Internet email: email software and transport systems are instructed to ignore any lines in email message headers that they don't recognize. So MIME email messages have the same set of email header lines as standard email messages, with a few lines added that describe the MIME content of the message:
  • MIME-version: declares the email to be a MIME message.
  • Content-Type: specifies type of data contained in the body of message. The content-type has two parts separated by a slash (/): the top-level "type" declaring the general type of the data -- text, image, video, and so on -- and a "subtype" giving its specific format. It includes an optional "charset" parameter that specifies the character set representation being used for the message.
  • Content-Transfer-Encoding: specifies how the data has been encoded for transport.

Back to Contents

 
     
How You Do MIME
  It's simple. To send a file, you "attach" it to a note; to receive a file is even easier -- your MIME user agent will recognize the attachment and offer to receive it. (It could display it instead, but that will take a bit more work on your part. See Configuring MIME.)

What does this do for you? Well, you could use Eudora to send an HTML file from your PC or Mac to your ADN UNIX account, and then use pine receive it into your pubic_html directory. Does that sound useful?

Back to Contents

 
     
Sending a File with Eudora
  A few of the Eudora "switches" and "configuration" options apply to MIME attachments; you can set them manually each time you send or receive a file, but it might be easier if you have Eudora automatically set them to your preferences.

Two switches (Special --> Switches) apply when you send files: "Always as Attachment" can either be selected or not; "Encode with" should be MIME (for Eudora for Windows) or Apple Double (for Eudora for Macs; in spite of the name difference, this is MIME). The configuration (Special --> Configuration) option "Automatically Receive Attachments" applies when you receive files. If you select this option, Eudora will automatically receive any attachments into the specified directory or folder (click the directory name to change the attachment directory or folder from Eudora's suggested default), using the attachment's original name. But you might prefer not to select this; then Eudora will ask you what you want to do with the file before it receives it.

To attach and send a file with Eudora: Open your note as usual (Message --> New Message), address it, and type the subject and body of the note (it doesn't have to have a body). The fully qualified name of the attached file(s) will be displayed on the "Attachments" line. You don't type the file's name; instead select Message --> Attach Document to open the "Attach Document" dialog box. Use it to select the file you want to send -- it's just like any other dialog box you use to select a file. (Repeat if you wish to attach more files -- a GIF image to go along with the HTML file, perhaps?) Then send the note as usual.

Back to MIME Contents

 
     
Receiving a File with Pine
  Pine is an easy-to-use email system in general, and MIME attachments only add a small wrinkle. To read incoming mail with MIME attachments: Login to your UNIX account, enter: pine then type: i (Folder Index) to display your INBOX. Use the up or down arrow keys to highlight the note you want to read, then press Enter or type v (ViewMsg) to view it. Figure 1 shows a note with two MIME attachments displayed in Pine. The attachments are listed at the top. (Note that the message body is considered an attachment, but it's "Shown".)

While you're viewing the note, type v (ViewAttch). Pine will list the attachments. Highlight the file you want to receive and type s (Save). Pine will offer to save the file, with its original name, in your home directory. Pine always saves the file in your home directory by default, even if you've entered pine while you're in a different directory. If that's OK, press Enter and you're done.

If you'd rather put the file in your public_html directory, use the left arrow key -- not Backspace (unless you want to also change the file's name, which you might want to do to make the name lowercase) -- to move before the name and type: public_html/ (so if the file's name was CAMP.HTM, you'll have: public_html/CAMP.HTM). If you want to put it into an entirely different directory, say your department's WWW directory, be sure to include the leading slash: /usr/local/etc/ ... and so on. The file will have read/write permissions only for you, it's owner, so you will have to do a chmod to make it publicly available on the WWW.

Back to MIME Contents

 
     
A Sample MIME Message
 

I sent the note shown in figure 1 to my account on tigger; its MIME header fields are shown in bold.

Figure 1a. A Multipart Multimedia MIME Message.

Below is the beginning of an email message with MIME attachments; the MIME header lines are shown in bold. The same note is shown after it, as you'd see it in Pine.

Note the boundary string in the Content-Type header line. This string, preceded by two dashes, is placed in the message body before each part of the message. The same boundary string, with two dashes before and after it, marks the end of the last part of the message's body.

Date: Tue, 3 Sep 1996 09:25:52 -0700 (PDT)
From: Judith Grobe Sachs <judygs@uic.edu>
To:  Judith Grobe Sachs <judygs@uic.edu>
Subject: A MIME Example
Message-ID: <.\Pine.PCW.3.95.96090316.63B110@judys.cc.uic.edu>
X-X-Sender: judygs@tigger.cc.uic.edu
MIME-Version: 1.0 Content-Type: MULTIPART/MIXED;
BOUNDARY="5494-19501-841=:9866"

--5494-19501-841=:9866
Content-Type: TEXT/PLAIN; charset=US-ASCII
This is the regular text body of a sample message with MIME.
... the rest of the plain text body ...

-5494-19501-841=:9866
Content-Type: VIDEO/x-msvideo; name="MACAW.AVI" 
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.PCW.3.95.96090351.63C@judys.cc.uic.edu>
Content-Description: This is a MS movie.

UklGRrC3AQBBVkkgTElTVNQHAABoZHJsYXZpaDgAAACFRQEAUccAAAAAAAAQ


Figure 1b. This same note, as displayed in Pine.

PINE 3.95  MESSAGE TEXT                       Folder: INBOX Message 64 of 64 ALL



Date: Tue, 3 Sep 1996 09:25:52 -0700 (CDT)
From: Judith Grobe Sachs <judygs@uic.edu>
To: Judith Grobe Sachs <judygs@uic.edu>
Subject: A MIME Example
Parts/attachments:

   1 Shown   7 lines  Text
   2   OK  116 KB     Video, "This is a MS movie."
   3   OK   24 KB     Audio, "This is a .WAV sound clip."
---------------------------------------

This is the regular text body of a sample message with MIME.

Judy Grobe Sachs

Judith Grobe Sachs +*+ Computer Center, University of Illinois at Chicago
(312)996-3758, fax 996-6834 +*****+ If you don't get everything you want, 
judygs@uic.edu +*+ think of the things you don't get that you don't want.

  [Part 2, "This is a MS movie."  Video/X-MSVIDEO   155KB]
  [Not Shown. Use the "V" command to view of save this part]

  [Part 3, "This is a .WAV sound clip."  Audio/X-WAV  33KB]
  [Not Shown. Use the "V" command to view of save this part]


                            [ALL of message]
? Help         M Main Menu    P PrevMsg     - PrevPage     D Delete     R Reply
O OTHER CMDS   V ViewAttch    N NextMsg   Spc NextPage     U Undelete   F Forward

The top-level content-type of a MIME message with multiple body parts is "multipart", and the content-type header line includes the "boundary-string" parameter, which defines the string that separates the different parts of the message body. The subtype in the sample message is "mixed" because its body parts are different types of data. In multipart/mixed messages, each part of the message has its own MIME content fields describing it.

The first body part of the sample MIME message is a standard email message; like all standard email messages, its content-type is:

Content-Type: TEXT/plain; charset=US-ASCII
This is the default MIME content-type. The content-type of video file in the sample message is video/x-msvideo. The "x" in the subtype means that it is not yet registered. The .wav audio file is also an unregistered type: audio/x-wav. Both video/x-msvideo and audio/x-wav are common enough that there's a chance that other MIME user agents will know about them. (Netscape Navigator does, for example.)

The text/plain part of the sample message's body is already in 7-bit US ASCII, so it didn't need to be encoded for transport and it didn't need a content-transfer-encoding field. (If it had one, its content-transfer-encoding would be 7bit.) The video and audio files are binary, so they were automatically encoded for transport.

Thus the video has:

Content-Transfer-Encoding: BASE64
Base64 is the binary to 7-bit ASCII encoding scheme developed for MIME; MIME user agents automatically encode (and decode) binary files using base64 encoding.

The encoded version is somewhat larger than the original file. (Compare the two sizes displayed by Pine in figure 1.)

Back to Contents

 
     
More on Content-Types
  The MIME content-types are probably the most important innovation in MIME. There are only seven top-level content-types: application, audio, image, message, multipart, text, and video. The MIME designers consider these seven types to be "substantially complete"; it is expected that current and future expansion will be accommodated by the addition of new registered subtypes.
The text content-type
is for human-readable data, which can be several different character sets. Standard email messages are text/plain, but there are several additional text subtypes (including text/HTML) that support basic formatting so that the body of message might have bold, italic, underlining, font and color changes, and the like.
The multipart content-type
allows you to combine different body parts, perhaps of different types, in a single message; each part of a multipart message has its own content-type.
The audio, image, and video content-types
are just what you'd think they'd be, although they have fewer registered subtypes than you might expect.
The application content-type
is for other types of application-related data. The registered subtypes include: applefile and mac-binhex40; octet-stream for sending binary files, with parameters that tell the receiving mail system (and person) what to do with the file: name, type, conversions, and padding; and various word processing subtypes including ones WordPerfect and MS WORD. MIME user agents use application/octet-stream for files they don't recognize.
The message content-type
is for including a complete email message within the body. You might not think that this type is useful, but consider two of its subtypes: message/partial, which breaks very large messages into parts, enabling the transmission of email bodies that are too large to be sent by email transport methods; and message/external, which indicates that the actual body is not included in the message, but gives instructions on how and where to go get it.

See the MIME FAQ for more information on MIME content-types; it's in the Ohio State FAQ archives: http://www.cis.ohio-state.edu/text/faq/usenet/mail/mimefaq/top.html

The registration process for content subtypes, character-set names, and other MIME types that are expected change uses the Internet Assigned Numbers Authority (IANA) as a central registry. The latest list is always at: ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/ 

Back to Contents

 
     
More on Transfer Encoding
  In addition to base64 for encoding binary files, MIME provides another type of transfer encoding that you've probably already seen: quoted-printable. It's for data that's already for the most part printable ASCII characters.

Quoted-printable encoding leaves printable ASCII text alone, but any character that is not US ASCII is represented by an equal sign (=) followed by the character's numerical representation in the form of two hexadecimal digits.

Quoted-printable encoding also splits lines that are longer than 76 characters after the 75th character, ending the first part of the line with an equal sign. (And have you ever received mail that had "=20" at the end of some lines? That's also quoted-printable encoding, to indicate that there was a blank at the end of that line; some email systems strip off -- or add -- trailing blanks.)

Eudora uses quoted-printable encoding by default. These stray equal signs can make your notes look a bit messy when viewed by a non-MIME-aware email system; that's why we recommend that you turn quoted-printable off when you're using Eudora to compose ordinary notes. With it off, Eudora composes email in regular 7-bit US ASCII, with no extra equal signs.

Back to Contents

 
     
Configuring MIME
  OK, so now we know what the MIME header fields are and what they mean. But how do MIME-aware email software and World Wide Web servers decide what the content-type of a particular file is? How do email software and Web browsers know what to do with the text/html and video/x-msvideo files they receive?

Well, assuming for the moment that you're not using a Mac, how would you tell? (If you are using a Mac, you're probably wondering what the problem is -- the file's resource fork has all the information you'd ever need.) You'd look at the second part of the file's name -- its file extension. The extension tells you that mail.gif is a GIF image, index.html is an HTML FILE, and so on.

That's exactly how MIME user agents tell. When a MIME user agent sends out a file, it looks up the file's content-type in a table that associates MIME content-types with specific file extensions, and when a MIME user agent receives a file, it looks the file's content-type in a table that associates content-types with the commands and options to display them.

In UNIX, these tables are in the files .mime.type and .mailcap, respectively. In personal computer MIME user agents, this information tends to be set and stored as "options" or "preferences". In Netscape, for example, the MIME content-types, extensions, and associated commands are set in General Preferences (see figure 2).

 

Figure 2. Configuring MIME Actions in Netscape. In Netscape, select Options --> General Preferences, then click the Helpers tab. This particular PC has WordPerfect for Windows but not MS Word. WordPerfect can read Word files, so the action to be taken for application/MS WORD is to open the file in WordPerfect.


Configuring Eudora to recognize and display MIME content-types is a bit more complicated. For Eudora Pro for Windows, it's explained in "Appendix D -- MIME and Mapping" in the Eudora manual (which, incidentally, includes brief introduction to MIME and a nice example of quoted-printable encoding). If you're on the adventurous side, it involves editing your eudora.ini file, in the section labeled [Mappings]. The mappings labeled in=, out=, and both= are for incoming, outgoing, and both. There are five parameters separated by commas: the PC file extension, the Mac creator code, the Mac type, the MIME type, and the MIME subtype. (Not all mappings have all five parameters, but you must have all four commas.)

Back to Contents

 
     
File Transfer with MIME
  File transfer with FTP (File Transfer Protocol) is important, useful, and quite common, but it has significant limitations: it only works on networks running TCP/IP, and you must own or have received permission to use the accounts on both end of the transfer.

Email has neither of these problems. So file transfer by email certainly has its place, and MIME makes it possible. If email software used on both ends is MIME-aware (MIME user agents), email is by far the best, easiest, and most fun way to exchange any type of file between two computer accounts. Sending or receiving email with attached files with a MIME user agent is not much harder than sending email without attached files.

But just being able to send or receive the file is not enough. There are two additional considerations that you must take when the file you want to transfer is one that will be used by a program. (Or, for that matter, when it is an executable program itself.)

Back to Contents

 
     
The First: a Question
  Will the person receiving your file be able to use it?

This is a problem more often than you might think. Not everyone uses the same version of the same software on the same platform (type of machine and operating system). So, a person using a PC running Windows will probably not be able to use a Mac BinHex file. And the .doc file you create with Word 6 isn't going to be of much use to your colleague who only has Word 2.

So, first ask the person who's receiving the file what type of file they can handle. But even if you have WordPerfect for Windows 6.1 and they have Word 2, don't worry, you'll be able to accommodate them. WordPerfect 6.1 has 39 choices for "Save as file type" on its "Save as" dialog box (in its File menu), including four for MS Word 2. Or you might want to save the file in a special file format such as Microsoft's RTF (Rich Text Format) that can be easily handled on both ends. (There's even a content-type for RTF files -- application/rtf. Configure your MIME user agent to open the RTF file in the word processor of your choice.)

If the file you're transferring is data that will be used with a database, spreadsheet, or statistical program, you might have to do something special to prepare a file that's suitable to be sent. The documentation for the program should tell you what you need to do to prepare the data; often you have to "export" it in a special form for transport. Here too you'll also have to take into consideration whether the person who will receive the file has the right program (and the right version of the program) to handle the file.

Back to Contents

 
     
The Second (and it's a big one): Viruses
  Now that I've gotten you all excited about the prospect of sending files with MIME (at least, I hope I have), here's a downside: You cannot spread or become infected by viruses (of the computer type, that is) by sending or receiving plain email. You can, however, do either when you send or receive files as MIME attachments. Text files are OK, but executable files (like .com and .exe files) and, yes MS Word .doc files, aren't. So if you're sent an MIME attachment that you didn't expect, don't save or use it. And check your machine for viruses before you send one.

(In case you think this couldn't happen to you, think again. It could. The latest virus scare on the 'Net, the Hare virus, is known to have been spread via posts to Usenet/Netnews newsgroups.)

 
When shouldn't -- or can't -- you use MIME to transfer files? See File Transfer is more complicated if

Comments are welcome; send them to
Judith Grobe Sachs, judygs@uic.edu

 
 

The ADN Connection, Sept/Oct 1996 Previous: Public Labs Require Passwords Next: A Brief Email History


1999-9-10  connect@uic.edu
UIC Home Page Search UIC Pages Contact UIC