| A Beginner's Guide to E-Mail |
Electronic mail is a wonderful tool which allows you to send high-speed messages virtually anywhere in the world. We will introduce you to the basic commands for reading and sending mail. You can get thorough documentation by reading the man pages (by typing man mail).
There are several ways to read and send e-mail; this document introduces the most standard, called simply mail. In order to master mail you must be able to use the more program and (by default) the vi editor. This is because you read files with more and write (edit) them with vi. If you are not familiar with more or vi, learn about them.
Mail operates in three modes:
Type mail at your Unix prompt to read your new mail. You are put into command mode, as described below.
Type mail -f at your Unix prompt to read the mail saved in your default file. Type mail -f filename at your Unix prompt to read the mail saved in filename. In either case you are put into command mode, as described below.
Type mail username to send mail to username. You are put into send mode, as described below.
The nice thing about command mode in mail (which is when you see the Mail> prompt) is that if you forget what your commands are, you can type a ``?'' at the Mail>, like this:
Mail> ?
Mail will then give you a brief listing of the command mode commands. Here are the ones you should learn first. (In this table, k stands for any positive integer, file stands for any filename, username stands for any username, keys you strike are in boldface, and you conclude each command by striking a Return.)
Return key Displays the next message
p Displays the current messages (the one you just read)
h Displays headers of messages, with message numbers
k Displays the kth message
s k file Saves the kth message in a file called file
(for example Mail> s 3 ~/grades will save message 3
in a file called grades in the top of your home directory
if the file exists, your message is appended to the file)
m username Sends a message to user username (see send mode below)
? Displays a cryptic message explaining other commands
There are other commands, but these are the most useful.
This is used when reading some specific message, not at the Mail> prompt. When reading messages, if the message is longer than your window can display, mail behaves just like more: you can scroll forward through the message by hitting the space bar, or (on some machines) backward by hitting a b, or you can quit looking at the message by hitting the q key. Other more commands you may know will also work.
This is used when sending messages from the Unix prompt or from mail's command mode. As an example, to send mail to user einstein from the Unix prompt, type the command
mail einsteinThe first thing that will happen when you enter send mode is that mail will prompt you for a subject, meaning a few choice words describing what the message as a whole is all about. After typing a subject and hitting Return, you can enter your message. The best idea is to use vi to create your message. To do so, type
~v(tilde v) at the beginning of some line. When you hit Return, you will enter the vi editor. (You can arrange for another editor, if you like; see the manual page.) If you have already typed some of your message, you will edit that. Otherwise, you will edit a blank file. Once in vi, edit your message until you are happy with it. Then exit vi in the usual way.
Here is the confusing part: when you leave vi, you will be back in mail's send mode, not at the Unix prompt! To exit send mode and mail your message, type (at the beginning of a line) a control-d, that is, hold down the Control key and the d key at the same time. Mail may then ask you to whom you want to send ``Carbon Copies'' (Cc:) of the message. If (as is usual) you don't want carbon copies, just hit Return.
If you want to abort sending the message, hit control-c twice. The second time is to confirm that you really want to abort the message.