|[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]|
The primary means of sending plain-text messages (or binaries in attachment files) between users across computer networks and systems on the Internet is called electronic mail, or email (and more often than not these days, just "mail").
The number of email applications (called mail user agents, or MUAs) available for Linux is large, and you could spend endless hours exploring the details of all of them. Instead of guiding you toward this route, this chapter attempts to do three things: give a brief intro to using the default mail agent; give an overview of other well-supported mail agents, with pointers on where to go for more info; and show how you can use other tools on the system to manipulate your email.
NOTE: On some Unix-based systems, the name of the tool is
mailx instead of
To send an email message with
$ mail email@example.com [RET] Subject: Hello [RET] Hi there, long time no talk! I'm just learning how to use [RET] Linux and thought I'd show you how easy it is to send email! [RET] C-d Cc: [RET]
The text you type on the `Subject:' line is displayed as the
subject of your email message, and the lines of text you type after that
is the body text of the message. Type C-d on a line alone to end
the message. Then,
When you type,
That's it! No bells, no whistles -- but no time-wasting excess, either.
To send an email message to another user on the same system, give their username on the system instead of an email address (technically, you are giving the email address, since email addresses take the form of username@hostname; when hostname is omitted, the localhost is assumed).
mrson your local system, type:
$ mail mrs [RET] Subject: are you going to the party tonight? [RET] C-d Cc: [RET] Null message body; hope that's ok $
This command sends an email message to the user
mrs on the local
system. The email message itself is empty, but the subject is a short
note asking whether user
mrs will be attending a party.
NOTE: Besides being good for sending mail to users that you
might share your system with,
$ mail firstname.lastname@example.org < trades [RET]
A variation on the previous recipe is to use
lynx Web browser
(see Reading Text from the Web).
$ mail email@example.com < lynx -dump -number_links http://etext.org/ [RET]
The following table lists the special keystrokes that work when
|| Abort the current message and exit |
|| On a blank line, either of these commands sends the message and
then exits |
||Erase the current line and move the cursor to the beginning of the line.|
||Run command in a shell.|
||Send a blind carbon copy to the usernames or email addresses given.|
||Copy the file `dead.letter' from your home directory into the message.|
|| Edit the message in the default text editor program. (When you exit
the text editor, you are returned to |
||Insert copies of the specified received messages into the message body. Messages are specified by number or a range (for example, `2-4' inserts messages two through four inclusive); if no number is given, the current received message is inserted.|
||Same as `~f', but reads in the messages with full headers.|
||Insert a copy of the file file into the message.|
||Write a copy of the body text into the file file.|
~f [RET] ~e [RET]
On Linux-based systems, the INBOX is a text file on the system
where your incoming mail is written to. Its location is always given by
$ echo $MAIL [RET]
Usually, the INBOX location is in the `/var/spool/mail' directory,
and has the same name as your username -- so if your username is
mrs, your INBOX is likely `/var/spool/mail/mrs'.
You shouldn't directly edit this file, because doing so can inadvertently cause you to lose incoming mail.
To see if you have any mail waiting in your INBOX, type mail. If
you don't have any mail,
$ mail [RET] Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/m": 3 messages 3 new >N 1 mrs Mon Sep 6 17:29 13/345 "Re: A modest proposal" N 2 Ray Tue Sep 7 04:20 15/694 "Latest news" N 3 lisa@example Tue Sep 7 09:35 19/869 "Re: Hello" &
In this example, the user has three messages waiting -- one from
mrs, one from Ray, and one from
When you type [RET] at the `&' prompt,
& 3 [RET]
There are two ways to exit
& x [RET]
To delete a message in
& d [RET]
& d3 [RET]
& d10-14 [RET]
The following table summarizes the most common
||Output a help menu containing a list of mail options and their meanings.|
||Delete a message. Give the number or range of the message(s) to delete as an argument.|
||Output a list of headers of mail messages. You can specify a range or the number of the message to start with.|
|| Exit |
||Reply to the message you last read; you can also give a message number as an argument to reply to that message number.|
||Undelete a message you have deleted in the current mail session. Give the number or range of the message(s) to be undeleted as an argument.|
|| Exit |
|| Save the message you last read to the file in your home directory
specified by file (if the file does not exist, |
A mail folder is simply a text file whose contents consist of saved mail messages; any tool that works on text can be used on a mail folder.
The following subsections describe some of the common ways to manage and otherwise modify your saved mail.
Debian: `elm-me+' WWW: http://www.instinct.org/elm/
You can view your mail folders in
less or edit them in a text
editor, although the folder will appear as one long scroll containing
all of the messages the folder contains.
You can also view them in
elm (see Picking the Right Mail Application) or open them with
To view a mail folder with
elm, give the name of the folder as
an argument to the `-f' option.
$ elm -f ~/email/mrs [RET]
If you save your mail messages in a lot of separate folders, you can
view a sorted list of all messages from all files by using
elm. Concatenate all the folders into one with
cat and then view that file in
elm as you would view any
$ cat ~/email/* > allmessages [RET] $ elm -f allmessages [RET]
These commands write a new file, `allmessages', in the current
directory, containing the contents of all email folders in
`~/email'; then, that file is viewed in
NOTE: To view a list showing who all the messages in a folder
are from, use
frm; see Seeing Who Your Mail Is From.
Debian: `biff' WWW: ftp://ftp.uk.linux.org/pub/linux/Networking/ WWW: http://www.splode.com/~friedman/software/packages/index.html
biff tool notifies you when new mail arrives, by printing the
header and first few lines of a mail message.
biff on, use `y' as an option. To turn
off, so that you stop being notified when new mail arrives, use `n'
as an option.
biff options don't take a hyphen.
$ biff y [RET]
Some people put the above line in their `.bashrc' file so that
biff is always set on in all of their shells (see Changing the Shell Prompt).
biff alone with no options will tell you whether
biff is set to `y' or `n'.
biffis set to, type:
$ biff [RET]
A companion tool,
xbiff, works only in the X Window System (you
can use the regular
biff in X, too). When you start it,
xbiff draws a window containing a mailbox that looks like
When you have mail,
xbiff rings the system bell, the window icon
reverses color, and the mailbox flag goes up:
NOTE: The original version of
biff was named after a
dog. In the early 1980s at a UC Berkeley computer lab, a girl would
bring her dog, Biff, with her when she went to use the computers. Biff
was known for barking at the mailman when he came in to deliver the
day's mail. He was also very popular with all of the BSD UNIX hackers at
Berkeley, and when one of them wrote a mail notification tool, he
thought of Biff -- hence the name. (Biff, the dog, died in August 1993.)
Debian: `elm-me+' WWW: ftp://ftp.uu.net/networking/mail/elm
messages to count the number of mail messages in a folder
or file. Give the name of a mail folder as an argument; with no
arguments, it counts the mail you have waiting in your INBOX.
$ messages [RET]
$ messages ~/email/saved [RET]
Debian: `elm-me+' WWW: ftp://ftp.uu.net/networking/mail/elm
frm to output a list of sender names and subjects for your
mail. Give the name of a mail folder as an option; with no options,
frm reads your INBOX.
$ frm [RET]
$ frm ~/email/saved [RET]
NOTE: An alternate tool,
from, works in similar fashion,
but it does not output subject lines; instead, it outputs the names of
senders and the time that messages were received.
Debian: `vrfy' WWW: ftp://ftp.nikhef.nl/pub/network/
vrfy to determine whether or not a given email address
works. This is useful when you are unsure whether or not you have the
right email address for someone. If the address works,
outputs a message indicating that the recipient exists; if the address
is not valid,
vrfy outputs a message saying that the user is
firstname.lastname@example.org valid, type:
$ vrfy email@example.com [RET]
Use the `-f' option to specify a text file containing email
vrfy attempts to verify all email addresses contained
in the file.
$ vrfy -f net-legends-faq [RET]
vrfy relies on the remote system to get this
information; in these days of the heavily corporatized Internet, an
increasing number of sites no longer supply this kind of information to
the general public. However, it's still useful enough to be worth
Debian: `metamail' WWW: http://bmrc.berkeley.edu/~trey/emacs/metamail.html
MIME ("Multipurpose Internet Mail Extensions") is an Internet standard for encoding and attaching files to mail messages. It's used when sending image, audio, or other non-plain-text data via email.
Normally, you read and send MIME mail with your MUA. The following
recipes, which show ways to send and receive MIME mail on the command
line, are useful for when you just use the
To read a mail attachment, write the message to a file and then run
metamail with the file name as an argument.
each attachment and prompts you about whether it should display the
attachment, write it to a file, or skip it.
$ mail [RET] Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/m": 1 messages 1 new >N 1 Photo Dept. Mon Feb 12 14:37 231/10980 "New Images" & w1 image.mail [RET] "image.mail" [New file] & x [RET] $ metamail image.mail [RET]
In this example, the
metamail was run with the file name as an argument.
To send a file as an email attachment, use
metasend. It prompts
for the values to use in the `To:', `Subject:', and `CC:'
header fields, plus the following values for each MIME attachment: its
`Content-type:' field, which describes the kind of data the
attachment contains; the file name; and the type of encoding to use, if
any (usually one is recommended).
$ metasend [RET] To: firstname.lastname@example.org [RET] Subject: The image you requested [RET] CC: [RET] Content-type: image/jpeg [RET] Name of file containing image/gif data: dream.jpeg [RET] Do you want to encode this data for sending through the mail? 1 -- No, it is already in 7 bit ASCII 2 -- Yes, encode in base64 (most efficient) 3 -- Yes, encode in quoted-printable (less efficient, more readable) 4 -- Yes, encode it using uuencode (not standard, being phased out) 2 [RET] Do you want to include another file too (y/n) [n] ? n [RET] Delivering mail, please wait... Mail delivery apparently succeeded. $
The following table lists values to use in the MIME `Content-type:' field for various kinds of files.
|| File compressed with |
|| File compressed with |
||JPEG image file.|
||PNG image file.|
||MP3 audio file.|
||WAV audio file.|
Debian: `sigrot' WWW: ftp://metalab.unc.edu/pub/Linux/system/mail/misc/
A signature file (often called a "dot sig," and written as `.sig') is a text file containing text that you want to appear at the end of email messages and other online postings.
Sometimes, people put their name, email address, and a small quote, or a
piece of ASCII art (such as text written in a
font---see Horizontal Text Fonts); once the World Wide Web
became popular, many people started including the URL of their home page
in their `.sig'.
The use of signatures goes in and out of vogue with the years; you can decide whether or not you want to use one, but whatever you do, be sure to keep your `.sig' at most four lines in length -- to use any more is considered very bad form. A first line consisting only of `-- ' is sometimes used; many applications recognize this text as the beginning of a `.sig' when processing messages.
You create your signature file in a text editor, just like any other text file. Name the file `.signature' or `.sig', and keep it in your home directory.
If you want to use more than one signature, use
"rotate" your various signatures -- every time you run
it selects one of the signature files you keep in your `.sigrot'
directory and writes it to `.signature'. To change your
`.signature' every time you log in, you would run
your `.bash_login' file (see The Shell).
The following table lists some of the more popular MUAs that are available for Linux, describing their special features, and listing their Debian package name and URL (when available).
|| A graphical email client that works in X with GNOME installed; its
interface is inspired somewhat by the proprietary Eudora.
|| A menu-driven MUA, |
Debian: `elm me+'
|| The |
|| MH-E is an Emacs front end to |
|| Netscape Inc.'s open source Web browser, |
|| The MUA currently in favor among many |
|| The Rand "Mail Handling" system, |
|| VM ("View Mail") is a facility for reading and sending mail in
Emacs. Older than |
|| Wanderlust is a MUA for Emacs designed to facilitate reading your
mail on multiple computers.
[<--] [Cover] [Table of Contents] [Concept Index] [Program Index] [-->]