Sequoia Hall
Home Academics Research Seminars Consulting Industrial Affiliates People
    
Computing Guide
Our Brochure
Contact Us
Sitemap
Links



7. Reading, Sending Mail

Previous Computing Guide Contents Next

It is worthwhile to understand some terminology in connection with electronic mail. All of us use what is called a Mail User Agent (MUA) to read and send mail. These are just front-ends to an actual Mail Transport Agent (MTA) which takes care of the complicated task of shuttling mail back and forth between various machines on the network.

As you can expect, there are many MUA's and each has a flavor all its own. In the PC and Mac World, there are programs like Eudora. In the Unix world there are programs like mail, Mail, mailx, Netscape, zmail, pine, elm, Emacs, MH, EXMH, that allow you to read and send mail. Unless you are a glutton for punishment, you'd probably want to avoid using the first three. I won't even discuss these three. Note that Emacs (see section Editors) is actually an editor but has integrated capabilities for mail. Within Emacs too, you have several choices like RMAIL, MH-E, VM, Mew, Gnus.

Caution The choice of an MUA is a personal decision. Furthermore, it can be quite tedious to switch from one mailer to another in the middle of the season as each mailer tends to save its files in its own particular format. Also note that some mail programs cannot handle attachments cleanly. If you expect a lot of attachments---current trends only seem to confirm this---you might want to use a mailer that can handle attachments cleanly. In fact, this is one of the main reasons I recommend not using mail, Mail and mailx.

I personally like using Emacs for my mail since editing is an important part of mail processing. Many have asked me why and here are some of my reasons.

Warning Opinionated section begins.

  • Emacs is a staple on all Unix systems these days. Therefore, the mailer I use, if it is bundled with Emacs, like Gnus or RMAIL are, will be available wherever I go. If I use other mailers within Emacs, the advantage still obtains since most Emacs packages can be installed in your home directory without bothering anybody.
  • I will get better at using Emacs which is worth everything.
  • People are always improving Emacs, in spite of the fact that there is no comparison with most editors.
  • Emacs is a religion.

That said, you should look into Netscape, zmail or pine which are all quite good. It is prudent to try out a few mail programs before settling on one. If you are the sort that tends to travel a lot, you should probably choose a mailer that is likely to be available in most places. If you decide to use a mail program in Emacs, you might prefer using XEmacs (see section Editors) because it has a nicer looking interface.

7.1 Mail on our machines
Even though we have different machines to log into, the mail is actually delivered to a central place on our network. So whichever machine you log into, you see the same mail.

If userid joe uses a pc program like Eudora on his pc or Mac which is connected to the network, he can still read his mail on the PC by telling Eudora his correct account name: joe@stat.Stanford.EDU and uses the POP protocol (IMAP will also be available soon). This works, no matter where you are, as long you as you have an internet connection. However, the slowness of such a connection from any place other than your own campus connection will almost certainly lead you to explore alternatives; see the section Mail Forwarding.

7.2 Organizing your mail
I'd go so far as to say that organizing your mail in a sane manner probably the most important activity in handling mail. There is no fixed recipe one can prescribe except to say that filing mail in folders is a good idea. Most modern mail programs will allow some kind of folder capability. In some cases, filing mail by subject thread might make sense, in others, organizing mail by sender might be more appropriate. The point, of course, is that you should be able to find messages you are looking for easily.

7.3 Handling Attachments
Attachments to mail messages make it easy to transfer any kind of data via e-mail. For example, if you have an audio file or an Excel spreadsheet and you want to send this to somebody, you can ``attach'' the document to a mail message you compose. You have to use an attachment procedure because mail programs handle only basic text data, whereas audio files and Excel spreadsheets and many other documents actually contain unprintable data. When one attaches a document to a mail message, it gets encoded into straight text, which when read looks like gibberish. The actual encoded document is preceded by some standardized headers that should not be tampered with. These headers provide mail reading programs information as to where the included document begins and ends in the message. They also provide hints for decoding the message.

Attachments are common these days and people in the PC world love them. They also tend to use them indiscriminately, not realizing that if they attach a document in a mail message to someone, that someone must also have a way of handling the document, which usually translates to that someone having the same programs for dealing with document as the sender of the e-mail. (I might add parenthetically, that I personally view them as a not-so-subtle form of Microsoft imperialism since most attachments tend to be either Microsoft Word or Excel documents.) Note that you cannot use the Microsoft Word or Excel files on our Unix systems because we'd need to have both of those programs installed on our machine to manipulate the files. Ugly and pricey alternatives exist and we don't have them on our systems. This doesn't mean that you cannot recover the Microsoft Word or Excel file from your mail message. If you use some of the modern mailers like pine or Emacs GNUS, you will have an option of saving the attached document. Once you have saved the file, you can transfer the document to some PC and use the Microsoft programs to handle them. If the document is not a Microsoft program document, but is something like a picture file (gif, or jpeg, or a PostScript file), your mail reader, if it is capable of handling attachments, will automatically invoke a viewer so that you can see the picture.

Netscape, zmail, pine, MH-E (with TM), Gnus (with TM), Mew all can handle attachments.

There is also a ``raw'' way to handle any attachment. Suppose someone sends you an attachment in a message. First, save the message to a file, say foo.mail. Then you can recover the attached document by running the program metamail over it.

rgmiller 1% metamail -w foo.mail

This program will ask you if you want to save the attachment. Just answer yes and the attachment will be saved as a file for you to deal with as appropriate. The name under which the file will be saved will also be shown. You can safely get rid of foo.mail after you save the document successfully.

Note: metamail invoked without the -w option might ask if you wish to send PostScript attachments to the printer, or open image files (i.e.,.gif, .jpg, etc) with xview, and so on, without the option of saving the attachment to a file.

One problem that can arise with attachments is that the encoding process actually makes the file bigger. Most mail programs have a limit on the size of a mail message they'll accept. If this is the case, the attachments need to be broken into smaller pieces called ``parts'' and transmitted. If you receive such a chopped up message, the ``raw'' method is likely to bomb---you'll really need a good mail program.

7.4 Mail forwarding
You can have your mail forwarded elsewhere by using a .forward file. Suppose userid joe wishes all mail coming to joe@stat.Stanford.EDU to be forwarded to joe@this-is-life.hawaii.edu, he only needs to create a file named .forward in his home directory with the new e-mail address joe@this-is-life.hawaii.edu and nothing else. Typically, one would use an editor to do this, but the following snippet at the shell prompt will do nicely.

rgmiller 1% echo "joe@this-is-life.hawaii.edu" > ~/.forward

Of course, when userid joe returns to reality from his vacation, he should just remove the .forward file for the forwarding to cease.

rgmiller 2% rm ~/.forward

A note of caution. Whenever you forward mail, be sure that there are no ``loops''. That is, make sure that whatever machine A is forwarding doesn't loop back to machine A. As you accumulate computer accounts elsewhere, this is a trap that even experienced users fall into.

To forward e-mail using procmail, please read this FAQ.

7.5 E-Mail Spams
A common problem these days is electronic mail spams, which are, simply put, indiscriminate e-mail solicitations. Spams can raise your blood pressure. If the number of these is small (I define this as about 3 a week), ignore them or better still filter them off (see section Mail Filtering). If it gets to be a nuisance, please forward one complete copy of the e-mail from the source, headers included, to junkmail@stanford.edu. Don't do this lightly as the security officer has plenty, and I really mean it, plenty of work.

Most importantly, do not try to reply to a spammer. In most cases, the return addresses are fake and your complaint will most likely bounce back to you as well as your annoyed system administrator. For more information, you should visit The Coalition Against Unsolicited Commercial Mail Web Page.

There are ongoing efforts in fighting spam, including an attempt at legislation that will make rules for bulk e-mail stricter. In addition, some mailers, vm for example, also have a ``complain'' mode, which can be invoked on a spam message to automatically extract the relevant headers and mail a packaged complaint message to the person in charge of the site from where the spam originated. Believe it or not, there is even a machine learning program now available to nuke spams.

7.6 Mail Filtering
Many interest groups have electronic mailing lists to which you can subscribe. You'll no doubt join a few. To prevent your important mail being intruded by mail that you might prefer to read at a more opportune time, you can use mail filters. Good mailing lists are designed to be filtered. Mail filters are simply programs that peek at your mail and process them according to some recipes before you see them. A really powerful mail filtering program called procmail is available on our system. In fact, we like it so much that it actually delivers mail for us. The upshot of this is that if to filter mail, you only need to create a .procmailrc file in your home directory with some recipes; a .forward file will work, but is unnecessary for mail filtering. For example, here is a snippet from my .procmailrc file (this assumes you are using the MH mail programs which may not be the case for you).

MAILDIR = $HOME/Mail         # You'd better make sure it exists
#DEFAULT = $MAILDIR/inbox/.
LOGFILE = $MAILDIR/procmail.log
LOCKFILE= $HOME/.lockmail
#
# Filter off S-news List
#
:0
* (^(To|Cc).*[Ss]-news)|(^(From|Return-Path).*s-sender)
S-news/.
#
# Trash all mail from those who have spammed me in the past!
#
:0
* (^(To|Cc|From).*makemoney.com)|(^(From|Return-Path).*makemoney)
/dev/null

:0
* (^(To|Cc|From).*suckers.com)|(^(From|Return-Path).*suckers.com)
/dev/null

The first recipe filters off all mail from a mailing list whose mail headers match the pattern described, and the last two make sure that mail from some net-scum never sees the light of day.

Note that mail filtering is in effect immediately after a file by the name .procmailrc is created in your directory.

Important To use procmail properly, you must read the man pages for procmail, procmailrc, and procmailex. You could lose mail if you do not know what you are doing.

7.7 Vacation Messages
If you are going to be away from your mail for some period of time and wish to notify those who send you e-mail, a program called vacation can help. This program allows you to craft a note which it will send to those who send you e-mail. It is intelligent enough to do so only once for n messages from a sender, where n can be chosen by you. To start the vacation program, type vacation and you will be led through the steps. Typing vacation again will allow you to disable the vacation message if you want. See the man page for vacation.

7.8 Department E-Mail Aliases
Some convenient system-wide e-mail aliases have been set up for addressing groups of people as a single entity. Lately, however, spammers have made life miserable and therefore, we have moved these aliases to the campus list server which rejects mail originating from outside stanford. To prevent robots from harvesting these addresses, we have placed them in a password protected area that any stanford community member can access.

7.9 Creating your own mailing lists
At Stanford, we have a facility to create mailing lists for people who need them. Of course, it is assumed that such mailing lists will be used for a good purpose and you'll have to justify the creation of such a list in the application form. The system administrator of the department does not handle mailing lists and all mail to him on this subject will be ignored. For more information on creating mailing lists see the Mailing List Server Web Page.


Previous Computing Guide Contents Next


Contact  | Sitemap  | Directories  | Maps  & Directions  | Giving to Stanford
Copyright 2004Stanford University. All Rights Reserved. Stanford, CA 94305, (650) 723-2300
Terms of Use Copyright Complaints