Reading (E-Mail Messages with) MIME attachments

First of all, the best way of reading MIME mail messages is using a MIME capable mail tool. Examples of such tools are pine, mutt, netscape, Eudora and probably a whole bunch of others. Such a mail tool does all the work for you. It detects the parts in a multipart message (attachments) and it decodes them into the native format of the type and tries to display or present them to you as they are intended to.

Of course it will only succeed in doing this correctly if it is configured correctly. This means that it should have the proper decoding algorithms or know where to find them and it should know how to display or present each type. Some mail tools can handle some types on their own (e.g. netscape can show gifs, jpegs, some videos, ...). Types a mail tool cannot handle, will be handed over to a helper application, provided of course the mail tool knows which application to use for which type. On Unix systems, such helper applications are configured in the .mailcap file in a system directory or in a user's home directory.

Such a .mailcap file is very simple. It describes what to do with specific MIME types, by specifying the MIME type in question and the action with which to manipulate documents of that type. You can create or edit your .mailcap file by hand. Some applications (e.g. netscape) can edit it for you, by means of their own preferences and configuration (look for (Helper) Applications in the Navigator group in the Preferences window).

If you edit it by hand, you need to specify the MIME type and the action on a single line, separated by a semi-colon :
application/msword; wordview '%s'
The quotes around the %s are necessary for documents with blanks in their name.
Using this .mailcap file, your mail reader (and any other tool that uses the .mailcap file, e.g. metamail) will use the wordview tool to view documents of the application/msword MIME type.
(This will of course only work if the sender of the E-Mail characterized the attachment with the correct MIME type ... if what he sent really is a MS Word document, but he specified the wrong MIME type, you cannot expect your E-Mail reader to detect this mistake ;-)

Mostly a MIME capable mail tool will present you a list of attachments and will allow you to select one of them and display/present it to you in its native format. In the same way does such a mail tool provide an interface for composing MIME messages, without having to worry about the exact syntax of the different parts and encoding them.


The rest of this text is intended for those who do not have a MIME capable mail tool or who, for some reason, do not want to use such a tool for reading their mail. You can decode a MIME message you have received in your mail without a MIME capable mail tool, but you cannot compose such a mail without having a fairly good knowledge of the MIME standard and the mail transfer agent on your platform.

You can detect a MIME encapsulated mail message by looking at the headers of the mail or by looking at the contents of the mail. Such messages are structured as explained in this text. In short: if there is a header in the mail like Content-Type: followed by something else than text/plain you will probably not be able to interprete the contents of the mail as they are. Furthermore, if the mail is structured in several parts, each part delimited by a specific string on a line on its own and each part characterized by a Content-Type: header of its own, you are reading a MIME message composed of several attachments. Again, you will probably not be able to interprete the individual parts because they probably are encoded into seemingly random ASCII text.

What not to do with a MIME mail ?

Do not forward it to somebody else unless you are using a MIME capable mail tool. If your mail tool is not MIME capable, forwarding such a mail will make it undecodable for the mail tool of the person you are forwarding it to, even if that other person uses a MIME capable mail tool. That's because forwarding a mail wraps it in a new set of headers and thus the receiving part doesn't get to see the MIME information in the original set of headers.
Instead of forwarding such a mail, you could bounce it to somebody else. Bouncing preserves the original set of headers and thus the other person will be able to decode the mail.
But there really is no need passing on the hot potato; decoding a MIME encapsulated mail is quite easy.

What to do with a MIME mail (without a MIME capable mail tool) ?

Just save it in a file. Every mail tool offers the option to save a mail in a file. How to do that depends of course on what tool you are using. Be sure to save it in a file of its own. No other mails, text or data besides that mail is allowed in the file.

Having saved the MIME mail message in a file of its own, execute metamail with the file name as its only argument. Metamail will show you the individual parts in the mail using helper applications as described above. For parts for which it doesn't find helper applications, it will prompt you what to do with it: displaying it as binary data, saving it in a file or skipping that part. Provided metamail is correctly configured by your system administrator or by yourself, most parts will be presented to you in their native format. Other parts can be saved and afterwards you can manipulate them with the proper tools (e.g. MS Word documents with MS Word, ...).

The file /cw/www/system/services/e-mail/mime.mail contains a MIME encapsulated messages composed of 5 parts : the first part is just plain text, the second is a gif image, the third is text in the iso latin 1 character set, the fourth is a MS Word document and the fifth is again just plain text. Try to decode it using metamail /cw/www/system/services/e-mail/mime.mail. If you have any problems or it doesn't work out as it is described in this text, please contact the programmeur van week.