2Apr il 2003, 17:00:47 The Complete FreeBSD (mua.mm), page 469
26
Electronic mail:
clients
In this chapter:
• Mail, for mats
• Mail user agents
• Files,folders or
director ies?
• Replying to a
message
• Using folders
• Deleting messages
• Tagging messages
• Configur ing mutt
• Mail aliases
• Mail headers
In this chapter:
• Mail, for mats
• Mail user agents
• Files,folders or
director ies?
• Replying to a
message
• Using folders
• Deleting messages
• Tagging messages
• Configur ing mutt
• Mail aliases
• Mail headers
Electronic mail,usually called email, e-mail or simply mail,isamethod of sending
and hence sent by RFC 2822, and also howtodivide the single RFC 2822 body into
multiple parts using ASCII separators.
MIME is one area in which UNIX is weak. ManyUNIX users consider themselves
Real Men who don’tneed these fancytoys. This is a pity.Incountries likeGermany,
people can get by with ASCII, but that doesn’twork in Japan, Israel or Russia.
In case you’re wondering, German has sevenspecial characters Ä, Ö, Ü, ä, ö, ü and ß. ßis
lower case only.There is a national standard defining howtorepresent these characters in
US-ASCII: replace the characters with Ae, Oe, Ue, ae, oe, ue and ss respectively.
There are plenty of good MIME-aware mail readers available for UNIX. It’sagood
idea to use one. On the other hand, if your target audience typically does not use
MIME-aware mailers, you should probably avoid sending MIME messages.
Mail user agents
A mail user agent is a program that interfaces between the user and the mail system. It
allows the user to read, forward and reply to incoming mail, and to send his own mail.
Beyond that, it usually has facilities for creating and maintaining folders,where you can
keep receivedmail messages. Formost UNIX MUAs, a folder is the same thing as a file,
butsome MUAs, which we won’tdiscuss here, keep mail messages as individual files,
and the folder corresponds to a directory.
mail
The oldest MUAyou’re likely to meet is mail.It’savery basic, character-oriented
program, but nevertheless it has its advantages. You can use it in scripts to send mail.
Forexample, if you have a job running and producing copious output, where you want to
save the output, you might normally write something like:
$ longjob 2>&1 > logfile
This command runs longjob.The sequence 2>&1 redirects the error output to the
standard output, and the > writes them to the file logfile.While this is a good way to
solvethe problem, you might find that you have a lot of such jobs, or that you tend to
forget the log files and leave them cluttering up your disks. An alternative istosend
yourself mail. Youcan do this with the following command:
mua.mm,v v4.12 (2003/04/02 04:07:59)
approach is more robust (if you trash a file, you only lose one message, not all of them),
and it enables you to have the same message in multiple folders. On the other hand, it
also imposes a lot higher overhead. Current versions of ufs,atleast on FreeBSD, have a
default block size of 16 kB and a fragment size of 2 kB. That means that all files have a
length that is a multiple of 2 kB, and so the average waste of space is 1 kB. In addition,
each file uses an inode. If you have a lot of mail, this can add up to a lot of wasted space.
Forexample, I currently have 508,649 savedmail messages, which takeupatotal of 2.1
mua.mm,v v4.12 (2003/04/02 04:07:59)
Files,folders or directories? 472
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 472
GB, almost exactly 4 kB per message. If I stored them in a directory structure, I would
lose about another 500 MB of space, or 25%. The file system on which the messages are
stored is 9.5 GB in size and has 1.2 million inodes; nearly half of them would be used for
the mail messages.
mutt
In this section, we’ll takeadetailed look at mutt.Start it by typing in its name. Like
most UNIX mailers, mutt runs on a character-oriented terminal, including of course an
xterm.We’ll takealook into my mailbox. By default, when starting it up you get a
display likethe one shown in Figure 26-1.
Figure26-1: mutt main menu
mutt sets reverse video by default. You can change the way it displays things, however.
On page 479 we’ll see howtochange it to the style shown in one shown in Figure 26-2.
This display shows a number of things:
• The line at the top specifies the name of the file (‘‘folder’’) that contains the mail
messages (/var/mail/grog), the number of messages in the folder,and its size. It also
states the manner in which the messages are sorted: first by threads,then by date.
We’lllook at threads further down.
• The bottom line givesabrief summary of the most common commands. Each
command is a single character.You don’tneed to press Enter to execute the
command.
mua.mm,v v4.12 (2003/04/02 04:07:59)
Files,folders or directories? 474
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 474
• The last column is usually the subject. Formessages 56 to 61, it’saseries of line
drawings. This is threading,and it shows a relationship between a collection of
messages on the same topic. Message 56 was the original message in the thread,
message 57 is a reply to message 56, and so on. Messages 60 and 61 are both replies
to message 59. mutt automatically collects all messages in a thread in one place.
You’ll notice in the example that the lines are of different intensity.Inthe original, these
are different colours, and they’re a matter of personal choice; theyhighlight specific kinds
of message. Iuse different colours to highlight messages on different topics. If you’re
interested in the exact colours, see />which contains an early version of this text.
Message 52 is appears to be in reverse video. In fact, it’sinwhite on a blue background,
acolour I don’tuse for anything else. This is the cursor,which you can position either
with the cursor up and cursor down keys, or with the vi-likecommands j (move down) or
k (move up). In the default display,itisinnormal video (i.e. not reversed, or doubly
reversed). You can also move between pages with the left and right cursor commands.
Manycommands, such as r (reply) or Enter (read), operate on the message on which the
cursor is currently positioned. Forexample, if you press Enter at this point, you’ll see a
display likethat in Figure 26-3.
Figure26-3: mutt message display
Here, the display has changed to showthe contents of the message. The top line now
tells you the sender of the message, the subject, and howmuch of the message is
displayed, in this case 50%. As before, the bottom line tells you the most common
commands you might need in this context: they’re not all the same as in the menu display.
The message itself is divided into three parts: the first 6 lines are a selection of the
headers.The headers can be quite long. Theyinclude information on howthe message
got here, when it was sent, who sent it, who it was sent to, and much more. We’lllook at
them in more detail on page 482.
The headers are separated from the message body by an empty line. The first part, which
somebody else. Normally there should be a line at the top stating who wrote it, but it’s
missing here. The text from the submitter starts with Tried patch.When you reply,
however, all this text is quoted again, so what you see on the screen is the display of
Figure 26-4. Here you see that the first line attributes the text below. You’ll notice that
this reply also includes a selection of headers for the outgoing message. This can be very
convenient if you want to tailor your headers to the message you’re sending, or just to add
other recipients.
mua.mm,v v4.12 (2003/04/02 04:07:59)