[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Lecture 9 Notes



These are the notes for lecture 9

Mark

-- 
Today's fortune:

	The future isn't what it used to be.  (It never was.)
Title: Math 481/581 Lecture 9: MIME

Math 481/581 Lecture 9: MIME

© 1998 by Mark Hays <hays@math.arizona.edu>. All rights reserved.


This document discusses the basics of MIME encoded email.


MIME and Mail

We met MIME earlier in the context of the WWW; today we'll take a brief look at how to handle MIME email (which is what MIME was originally invented for).

Specifically, we'll cover composing and sending MIME encoded messages using Netscape, and reading MIME messages with the Pine mailer.

If you choose to send people MIME encoded mail, remember to consider your recipient: this person will need to have the necessary software to decode your encoded message!


Sending MIME messages

Before sending mail using Netscape, you will want to set your identity under the Options/Preferences menu. At a minimum, your identity consists of your full name and email address (so that people can reply to you). You will probably also need to set your SMTP server for outgoing mail. If you don't know what server to use, ask your sysadmin.

Sending MIME encoded messages with Netscape is pretty easy. From the File menu, select "New Mail Message". A new window will pop up where you can type in the text of your message, the recipients, etc.

To attach a text file, HTML file, image, etc. to the message, click on the "Attach..." button. To attach a file, click the appropriate button and follow your nose until you're done.

Once you have finished composing your message, click "Send". That's it!


What Does An Encoded Message Look Like?

Here is how a piece of text and an image get encoded:
>From hays  Mon Sep 28 08:06:58 1998
Return-Path: <hays>
Received: (from hays@localhost)
	by dec.math.arizona.edu (8.8.5/8.8.5) id IAA09271
	for hays; Mon, 28 Sep 1998 08:06:57 -0700 (MST)
Received: from sahuarita.math.arizona.edu
	by dec.math.arizona.edu (fetchmail-4.3.2 POP3 run by hays)
	for <hays@localhost> (single-drop); Mon Sep 28 08:06:57 1998
Received: from amethyst.math.arizona.edu (amethyst.math.arizona.edu [128.196.224.2])
	by sahuarita.math.arizona.edu (8.9.0.Beta5/8.9.0.Beta5) with ESMTP id IAA12352
	for <hays@sahuarita.math.arizona.edu>; Mon, 28 Sep 1998 08:05:47 -0700 (MST)
Received: from dec.math.arizona.edu (dec.math.arizona.edu [128.196.224.146])
	by amethyst.math.arizona.edu (8.9.0.Beta5/8.9.0.Beta5) with SMTP id IAA08066
	for <hays>; Mon, 28 Sep 1998 08:05:52 -0700 (MST)
Sender: hays@math.arizona.edu
Message-ID: <360FA5FF.41C6@math.arizona.edu>
Date: Mon, 28 Sep 1998 08:06:39 -0700
From: Mark Hays <hays@math.arizona.edu>
Organization: Department of Mathematics, Univ. of Arizona
X-Mailer: Mozilla 3.0 (X11; I; OSF1 V3.2 alpha)
MIME-Version: 1.0
To: hays@math.arizona.edu
Subject: A Simple MIME message
Content-Type: multipart/mixed; boundary="------------167E2781446B"
X-UIDL: d6360199912e3903592e716d6e86e868
Status: RO
X-Status: 
X-Keywords:
X-UID: 1

This is a multi-part message in MIME format.

--------------167E2781446B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This is a simple MIME message -- it contains a picture.

Happy Viewing!
Mark

--------------167E2781446B
Content-Type: image/gif; name="home.gif"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="home.gif"

R0lGODlhPAARAMQAAP///xAQECEhITExMTk5OUJCQkpKSlJSUlpaWmtra3Nzc3t7e4yMjJSU
lJycnK2trbW1tb29vcbGxs7OztbW1t7e3u/v797e5wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ACwAAAAAPAARAAAF/yAgjmRpnmiqrmzrvnBMWk6CIIljybxrQQeBcHCA7GKFRU/lEBwakokD
IXDIkksURbCoUCQR8EJQQSocXRFNB7gsIg0GLQ2gLKykhMEyifghgDhIARAIGBUVAQwNARUS
GAgPARgQAwIADgEPB0ojVRdhfxFolzBYjxEKAyIDChEYEgAFBQALGAACSVQkARcTYBGAEA4K
AUhKrxEHtLIGqLK0trgIEmC8FH7BEA8PDQjGpsiwmRYWAQ7JAATRt2MVFhQkBAwTwg/DCwUE
MWcAEwUTas1SQoFAPAUKMDFzcODAAxIMBth7gIYKgywYR1wg8KRBHAUHBhC4kLGkhAJEDhYY
GBCgQKySJSt4u5GgAUmYOHPqzBgCADs=
--------------167E2781446B--
The first Content-Type line looks like:
Content-Type: multipart/mixed; boundary="------------167E2781446B"
This line says that the message body consists of several parts, each with its own Content-Type. The parts of the message body are separated with the string "------------167E2781446B" on a line by itself.

The first part of the message simply states that the message is MIME encoded.

The second part is plain text -- this part is the text I typed into the Netscape message composition window.

The third and final part is a GIF image encoded in base 64. In base 64, 3 bytes of binary data are encoded as 4 bytes of ASCII data. The base 64 "digits" are:

RangeEncoding
0-25A-Z
26-51a-z
52-610-9
62+
63/

In order to read this message in a meaningful way (to be able to see the GIF image, for example), you will need to use a MIME-enabled mail reader.

If you read this message with Berkeley Mail, you will see the message exactly as shown above (because Mail doesn't know about MIME).


Reading MIME Mail With Pine

Here I will assume that you do not normally use the Pine mail reader in day to day life. If you do use Pine, I strongly encourage you to reconsider your choice: Pine has some serious technical flaws (documented by Pine's author in the Pine source code) having to do with file locking. The upshot is that you can lose some or all of your email at random times if you use Pine.

I will also assume that you do not read mail with Netscape. Netscape (irreversibly, more or less) converts all of your mail into HTML. Most other mail programs store mail in standard UNIX "mbox" format, which allows these programs to interoperate with one another. For example, you can use a graphical mail program while in X windows and a terminal based mail program when logged in from home.

If you use Netscape, you are locked into it because other mail programs assume that your mailbox is in mbox format.

Instead, I will assume that you normally use Berkeley Mail and that you have received a MIME encoded message that you want to view. The first step is to save the message to a file using Mail's "s" command:

	& s mime
This will create a file named "mime" which contains the raw message in mbox format (as in the example above).

Next, get out of Mail using "q" or "x".

Pine stores your mail folders in $HOME/mail. You will need to create this directory if it doesn't already exist. If you already have a file or directory called "mail", you'll need to temporarily rename it and create a new directory for Pine.

Next, move the file "mime" into the "mail" directory and start up pine on the message:

	> mkdir mail
	> mv mime mail
	> pine -f mime
Follow your nose until you are reading the message. At this point, your screen will look something like:
  PINE 3.96   MESSAGE TEXT                Folder: mime  Message 1 of 1 ALL      

Date: Mon, 28 Sep 1998 08:06:39 -0700
From: Mark Hays 
To: hays@math.arizona.edu
Subject: A Simple MIME message
Parts/attachments:
   1 Shown     4 lines  Text                                                  
   2   OK    412 bytes  Image                                                 
----------------------------------------

This is a simple MIME message -- it contains a picture.

Happy Viewing!
Mark

  [Part 2, Image/GIF  550bytes]
  [Not Shown. Use the "V" command to view or 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  
As you can see, Pine knows that the message contains a GIF, but it cannot display it directly on the terminal. If you follow Pine's hint and hit the "V" key (in uppercase), your screen will look like this:
  PINE 3.96   ATTACHMENT INDEX                Folder: mime  Message 1 of 1      

   1      4 lines   Text/PLAIN                                                  
   2    412 bytes   Image/GIF                                                   


















? Help       E Exit Index P PrevAttch   - PrevPage    A AboutAttch              
             V [View]     N NextAttch Spc NextPage    S Save        W WhereIs  
If you aren't in an X windows session, you probably won't be able to display the GIF at all. In such a case, you can save the image to a file by hitting the "S" key.

Assuming that you are in X windows, and that $HOME/.mailcap (or the systemwide mailcap file) contains a line like:

	image/*; xv %s
you can view the image using the "xv" image viewer by selecting the GIF attachment and pressing the RETURN key. Hit the "q" key in the xv window to quit xv.

When you are done viewing attachments, hit "E" to get back to the message list, followed by "Q" to quit Pine.

If you receive an attachment that your mailer doesn't understand, the best you can do is to save it to a file and take it somewhere else. This will likely be the case if you receive an MSWord document on a UNIX system, for example.