mail - send mail to users or read mail
mail address [ address... ]
mail [ -ehpqr ] [ -f file ]
The command-line arguments that follow affect SENDING mail:
An address can be any one of the following:
1) An RFC 822-compliant address specification (i.e.
2) A UUCP route (i.e. ``host1!host2!user'').
3) A local user name or alias.
When addresses are specified, mail assumes a message is being sent. It
reads the text of the message from standard input up to an end-of-file
(control-d), or until it reads a line consisting of just a period. When
either of those signals is received, mail passes the message text and the
list of addresses to the sendmail(1M) program for further disposition.
If a letter is found to be undeliverable, it is returned to the sender
with diagnostics that indicate the location and nature of the failure.
If mail is interrupted during input, the file dead.letter is saved to
allow editing and resending. dead.letter is normally maintained by
sendmail, and the interrupted message will be appended to the previous
Reading Mail [Toc] [Back]
The command-line arguments that follow affect READING mail:
-e causes mail not to be printed. An exit value of 0 is returned
if the user has mail; otherwise, an exit value of 1 is
-h causes a window of headers to be displayed rather than the
latest message. The display is followed by the '?' prompt.
-p causes all messages to be printed without prompting for
-q causes mail to terminate after interrupts. Normally an
interrupt causes only the termination of the message being
-r causes messages to be printed in first-in, first-out order.
-ffile causes mail to use file (e.g., mbox) instead of the default
mail, unless otherwise influenced by command-line arguments, prints a
user's mail messages in last-in, first-out order. For each message, the
user is prompted with a ?, and a line is read from standard input. The
following commands are available to determine the disposition of the
<new-line>, +, or n Go on to next message.
d, or dp Delete message and go on to next message.
d # Delete message number #. Do not go on to next
dq Delete message and quit mail.
h Display a window of headers around current message.
h # Display header of message number #.
h a Display headers of ALL messages in the user's
h d Display headers of messages scheduled for deletion.
p Print current message again.
- Print previous message.
a Print message that arrived during the mail session.
# Print message number #.
r [ users ] Reply to the sender, and other user(s), then delete
s [ files ] Save message in the named files (mbox is default).
y Same as save.
u [ # ] Undelete message number # (default is last read).
w [ files ] Save message, without its top-most header, in the
named files (mbox is default).
m [ addresses ] Mail the message to the listed addresses.
q, or ctl-d Put undeleted mail back in the system mailbox and
x Put all mail back in the system mailbox unchanged
and exit mail.
!command Escape to the shell to do command.
? Print a command summary.
When a user logs in, the presence of mail, if any, is indicated. Also,
notification is made if new mail arrives while using mail.
The system mailbox permissions may be manipulated to alter the function
of mail. The other permissions of the file may be read-write, read-only,
or neither read nor write to allow different levels of privacy. If
changed to other than the default, the file will be preserved even when
empty to perpetuate the desired permissions.
Earlier versions of mail implemented an -F option which was used to set
up mail forwarding by placing special control text at the top of an empty
system mailbox. This option is no longer supported by mail in favor of
the more convenient and general mechanism provided by the .forward file
used by sendmail(1M).
When sending mail, mail does not insert a blank line at the beginning of
the body. Normally this is not a problem. However, if the first line
has the form of a valid header line (non-whitespace text, then a colon,
and then more text), some mail delivery agents will parse it as a header
line, find it invalid, and omit it from the delivered mail. When sending
mail (particularly from programs) that might (sometimes) start with such
a line, the problem can be avoided by making the the first line of the
body be empty; that is, just a newline.
/etc/passwd to identify sender and locate users
/var/mail/user incoming mail for user; i.e., the system mailbox
/var/mail/user.lock lock for user's system mailbox
$HOME/mbox saved mail
$MAIL variable containing path name of the system mailbox
/tmp/mail* misc. temporary files
/var/mail/:saved directory where temporary copies of the system
mailbox are written when it is being updated
dead.letter file where the text of last aborted message will be
login(1), mail_bsd(1), rmail(1M), sendmail(1M), uux(1C), write(1),
Internet RFC 822 - Standard for the Format of Internet Text Messages.
Conditions sometimes result in a failure to remove a lock file.
After an interrupt, the next message may not be printed; printing may be
forced by typing a p.
Upon successful completion, a value of zero is returned. Otherwise a
value is returned to to indicate the error:
1 flag 'e' error
2 file error
3 no space
4 cannot forward
5 syntax error
6 forwarding loop
7 invalid sender
8 invalid user
9 too many From lines
10 bad permissions
11 mbox problem
12 temporary file problem
13 Cannot create dead.letter
14 Unbounded forwarding
15 cannot create lock file - XXXrs
16 no group id of 'mail'
17 malloc failure
18 could not fork
19 could not pipe
20 invoker does not own mailfile
21 can't call sendmail
PPPPaaaaggggeeee 5555 [ Back ]