Receiving Mail with the Unix mail Utility

The basic no-frills Unix mail utility is called mail. It handles mail in the standard mbox format, the same format that many fancier mail utilities such as thunderbird and pine still use.

Once you have read a mail message, the Unix mail utility normally moves it from the system mailbox to your personal mailbox, a file usually called mbox in your home directory.

To read your new mail (system mailbox), type

If you have no mail in the system mailbox, you will be told so. If you have kept some of your previously read mail in your private mailbox, then type
   mail -f
and you will be looking at the contents of the file mbox instead of the system mailbox. If there is none, you will be told that your file mbox doesn't exist.

Here is a sample of what you may see:

mailx version 5.0 Wed Oct 13 14:50:03 PDT 1999  Type ? for help.
``/var/spool/mail/detar'': 2 messages 1 new
>U  1 jones                 Thu Aug  6 15:44  171/5256  Potts-flux-tube model
 N  2 Thu Aug  7  6:10  130/525   SSC
This is a list of messages in the order of receipt. Notice the message numbers in the second column. The sender's username is given, followed by the date of receipt, some information about the size of the message (lines/bytes), and the subject as supplied by the sender. The mail utility pauses to await further instructions. It issues a question ? prompt. To read message number 2, type
   more 2
which gives you a display one screen at a time, as with the Unix more command. (You can also simply type the number 2, but if there is more than one screenful, you will only see the last part of the message.) (Please note that with some brands of Unix mail does not understand more, so you may have to write an extra-long text message to a file, exit mail, and run more on the file.)

The first letter on the line gives the status of the message. The code U means ``unread'' and N means ``new''. The > marks the current message.

Here is a summary of some useful mail commands that may be typed at the & prompt.

? lists commands.
more <number> displays message number <number>.
h repeats the list of active messages.
d <number> marks a message for deletion.
w <filename> Write message to the named file
r Reply to the sender.
q Exit and apply changes.
  (Moves messages you have read to your mbox file
  and deletes messages marked for deletion.)
x Quit and leave the mailbox exactly as it was.
z List the next set of messages in your mailbox.