mail(1) General Commands Manual mail(1)
Name
mail - send or read mail
Syntax
mail [-v] [-i] [-n] [-e] [-s subject] [user...]
mail [-v] [-i] [-n] -f [name]
mail [-v] [-i] [-n] -u user
mail nodename::username (If DECnet is installed.)
Description
The utility is an intelligent mail processing system which has a command syntax similar to However, in lines are replaced by messages.
If DECnet is installed on your system, you can also send and receive mail from other DECnet users. See for information on DECnet address-
ing.
Sending mail. To send a message to one or more persons, type and the names of the people receiving your mail. Press the RETURN key. Note
that if you use other arguments, the names of the recipients should always be the last element on the command line. For example,
mail -v -s "mail message" users
If you do not specify a subject on the command line, you are prompted for a subject. After entering a subject, and pressing the RETURN
key, type your message. To send the message, type a period (.) or CTRL D at the beginning of a new line.
You can use tilde ( ) escape sequences to perform special functions when composing mail messages. See the list of options for more on
tilde escape sequences.
Reading mail. In normal usage is given no arguments and checks your mail out of the mail directory. Then it prints out a one line header
of each message there. The current message is initially the first message and is numbered 1. It can be displayed using the command.
The option causes mail not to be printed. Instead, an exit value is returned. For the exit status, see RETURN VALUES. You can move among
the messages by typing a plus sign (+) followed by a number to move forward that many messages, or a minus sign (-) followed by a number to
move backward that many messages.
Disposing of mail. After reading a message you can delete (d) it or reply (r) to it. Deleted messages can be undeleted, however, in one
of two ways: you can use the undelete (u) command and the number of the message, or you can end the mail session with the exit (x) com-
mand. Note that if you end a session with the quit (q) command, you cannot retrieve deleted messages.
Specifying messages. Commands such as and can be given a list of message numbers as arguments. Thus, the command
delete 1 2
deletes messages 1 and 2, while the command
delete 1-5
deletes messages 1 through 5. The asterisk (*) addresses all messages, and the dollar sign ($) addresses the last message. For example,
the command, which prints the first few lines of a message, can be used in the following manner to print the first few lines of all mes-
sages:
top *
Replying to or originating mail. Use the command to respond to a message.
Ending a mail processing session. End a session with the (q) command. Unless they were deleted, messages that you have read go to your
mbox file. Unread messages go back to the mail directory. The -f option causes to read in the contents of your mbox (or the specified
file) for processing. When you the mail utility writes undeleted messages back to this file. The -u flag is a short way of specifying:
Personal and systemwide distribution lists. You can create a personal distribution list that directs mail to a group of people. Such
lists can be defined by placing a line similar to the following in the .mailrc file in your home directory:
alias cohorts bill ozalp jkf mark kridle@ucbcory
Cohorts is the name of the distribution list that consists of the following users: bill, ozalp, jkf, mark, and kridle@ucbcory. A list of
current aliases can be displayed with the command in
System wide distribution lists can be created by editing The syntax of system wide lists differs from that of personally defined aliases.
Personal aliases are expanded in mail you send. When a recipient on a personally defined mailing list uses the option, the entire mailing
list receives the response automatically. System wide aliases are not expanded when the mail is sent, but any reply returned to the
machine will have the system-wide alias expanded as all mail goes through
Forwarding is also a form of aliasing. A file can be set up in a user's home directory. Mail for that user is then redirected to the list
of addresses in the file. See and for more information.
Network mail (ARPA, UUCP, Berknet, DECnet) See for a description of network addresses.
Options
-e Causes not to be printed. Instead, an exit value is returned.
-f Causes to read in the contents of your mbox file (or another file you specify) for processing.
-i Causes tty interrupt signals to be ignored. This is useful when using on noisy phone lines.
-n Inhibits the reading of /usr/lib/Mail.rc.
-s Specifies a subject on the command line. Note that only the first argument after the -s flag is used as a subject and that you must
enclose subjects containing spaces in quotes.
-u Specifies a short hand for expressing the following:
mail -f /usr/spool/mail/user
-v Prints the mail message. The details of delivery are displayed on the user's terminal.
The following options can be set in the .mailrc file to alter the behavior of the command.
Each command is typed on a line by itself and may take arguments following the command word and the command abbreviation. For commands
that take message lists as arguments, if no message list is given, then the next message forward which satisfies the command's requirements
is used. If there are no messages forward of the current message, the search proceeds backwards. If there are no good messages at all,
cancels the command, displaying the message: No applicable messages.
- Prints out the previous message. If given a numeric argument n, prints n-th previous message.
? Prints a brief summary of commands.
! Executes the ULTRIX shell command which follows.
alias (a) Prints out all currently-defined aliases, if given without arguments. With one argument, prints out that alias. With more
than one argument, creates a new or changes an old alias. These aliases are in effect for the current mail session only.
alternates (alt)
Informs that you have several valid addresses. The command is useful if you have accounts on more than one machine. When you
to messages, does not send a copy of the message to any of the addresses listed on the alternates list. If the command is
given with no argument, the current set of alternate names is displayed.
chdir (ch) Changes the user's working directory to that specified. If no directory is given, then the command changes to the user's login
directory.
copy (co) Takes a message list and file name and appends each message to the end of the file. The command functions in the same way as
the command, except that it does not mark the messages that you copy for deletion when you quit.
delete (d) Takes a list of messages as argument and marks them all as deleted. Deleted messages are not saved in mbox, nor are they
available for most other commands.
dp (or dt) Deletes the current message and prints the next message. If there is no next message, returns a message: at EOF.
edit (e) Takes a list of messages and points the text editor at each one in turn. On return from the editor, the message is read back
in.
exit (ex or x)
Returns to the Shell without modifying the user's system mailbox, mbox file, or edit file in
file (fi) Switches to a new mail file or folder. If no arguments are given, it tells you which file you are currently reading. If you
give it an argument, it writes out changes (such as deletions) you have made in the current file and reads in the new file.
Some special conventions are recognized for the name. A pound sign (#) indicates the previous file, a percent sign (%) indi-
cates your systemb mailbox, %user indicates the user's system mailbox, an ampersand (&) indicates your /mbox file, and +folder
indicates a file in your folder directory.
folders List the names of the folders in your folder directory.
folder (fo) Switches to a new mail file or folder. The command functions in the same way as the command.
from (f) Takes a list of messages and prints their message headers in the order that they appear in the mail directory, not in the order
given in the list.
headers (h) Lists the current range of headers, which is a 20 message group. If a plus sign (+) is given as an argument, then the next
message group is printed. If a minus sign (-) is given as an argument, the previous message group is printed.
help Prints a brief summary of commands. Synonymous with ?.
hold (ho, also preserve)
Takes a message list and marks each message in it to be saved in the user's system mailbox instead of in mbox. The command
does not override the delete command.
ignore Adds the list of header fields named to the ignored list. Header fields in the ignore list are not printed on your terminal
when you print a message. This command is frequently used to suppress certain machine-generated header fields. The and commands
are used to print a message in its entirety, including ignored fields. If is executed with no arguments, it lists the current
set of ignored fields.
mail (m) Takes login names and distribution group names as arguments and sends mail to those people.
mbox Indicates that a list of messages should be sent to mbox in your home directory when you quit. This is the default action for
messages if you did not set the hold option.
next (n, + or CR)
Goes to the next message in sequence and types it. With an argument list, it types the next matching message.
preserve (pre)
Takes a message list and marks each message in it to be saved in the user's system mailbox instead of in mbox . Synonymous
with the command.
print (p) Takes a message list and types out each message on the user's terminal, without printing any specified ignored fields.
Print (P) Prints a message in its entirety, including specified ignored fields.
quit (q) Terminates the session. All undeleted, unsaved messages are saved in the user's mbox file in his login directory; all messages
marked with or or that were never referenced are saved in his system mailbox; and all other messages are removed from his sys-
tem mailbox. If new mail arrives during the session, the user receives the message: You have new mail. If given while editing
a mailbox file with the flag, then the edit file is rewritten. A return to the Shell is effected, unless the rewrite of the
edit file fails, in which case the user can escape with the command.
reply (r) Takes a message list and sends mail to the sender and all recipients of the specified message. The default message must not be
deleted.
Reply (R) Replies to originator of the message. Does not reply to other recipients of the original message.
respond Takes a message list and sends mail to the sender and all recipients of the specified message. Synonymous with
save (s) Takes a message list and a file name and appends each message to the end of the file. The messages are saved in the order in
which they appear in the mail directory, not in the order given in the message list. The filename, which is enclosed in
quotes, followed by the line count and character count, is displayed on the user's terminal.
set (se) Prints all variable values when no arguments are given. Otherwise, the command sets the specified option. Arguments either
take the form
option=value
or
option
shell (sh) Invokes an interactive version of the shell.
size Takes a message list and prints out the size (in characters) of each message. The size of the messages are printed in the
order that they appear in the mail directory, not in the order given in the list.
source (so) Reads commands from a file.
top Takes a message list and prints the top few lines of each. The number of lines printed is controlled by the variable and
defaults to five.
type (t) Takes a message list and types out each message on the user's terminal, without printing any specified ignored fields. Synony-
mous with
type (T) Prints a message in its entirety, including specified ignored fields. Synonymous with
unalias Takes a list of names defined by commands and cancels the list of users. The group names no longer have any significance.
undelete (u)
Takes a message list and marks each one as not being deleted.
unset Takes a list of option names and discards their remembered values; the inverse of
visual (v) Takes a message list and invokes the display editor on each message.
write (w) Takes a message list and a file name and appends each message to the end of the file. Synonymous with
xit (x) Returns to the Shell without modifying the user's system mailbox, mbox , or edit file in Synonymous with
z Presents message headers in windowfulls as described under the command. You can move forward to the next window with the z
command. Also, you can move to the previous window by using z-.
The following is a summary of the tilde escape functions that you can use when composing mail messages. Note that you can only invoke
these functions from within the body of a mail message and that the sequences are only executed if they are placed at the beginning of
lines.
~!command Executes the indicated shell command, then returns to the message.
~? Prints a brief summary of tilde commands.
~: Executes the mail commands. (For example, the command prints out message number 10 while prints out the previous message.
~c name ... Adds the given names to the list of carbon copy recipients.
~d Reads the file named dead.letter from your home directory into the message.
~e Invokes the text editor on the message you are typing. After the editing session is finished, you may continue appending text
to the message.
~f messages Reads the named messages into the message being sent. If no messages are specified, reads in the current message.
~h Edits the message header fields by typing each one in turn and allowing the user to append text to the end or to modify the
field by using the current terminal erase and kill characters.
~m messages Reads the named messages into the message being sent, shifted one tab space to the right. If no messages are specified, reads
the current message.
~p Prints the message on your terminal, prefaced by the message header fields.
~q Aborts the message being sent, copying the message to dead.letter in your home directory if the save option is set.
~r filename Reads the named file into the message.
~s string Causes the named string to become the current subject field.
~t name ... Adds the given names to the direct recipient list.
~v Invokes an alternate editor (defined by the VISUAL option) on the message. Usually, the alternate editor is a screen editor.
After you quit the editor, you can resume appending text to the end of your message.
~w filename Writes the message onto the named file.
~|command Pipes the message through the command as a filter. If the command gives no output or terminates abnormally, retains the origi-
nal text of the message. The command fmt(1) is often used as command to rejustify the message.
~~string Inserts the string of text in the message prefaced by a single tilde (~). If you have changed the escape character, then you
should double that character in order to send it.
Options are controlled via the and commands. Options may be either binary or string. If they are binary you should see whether or not
they are set; if they are string it is the actual value that is of interest.
The binary options include the following:
append Causes messages saved in mbox to be appended rather than prepended. (This is set in /usr/lib/Mail.rc on version 7 systems.)
ask Causes mail to prompt you for the subject of each message you send. If you simply respond with a new line, no subject field
is sent.
askcc Asks you at the end of each message whether you want to send a carbon copy of the message to additional recipients.
Responding with a new line indicates your satisfaction with the current list.
autoprint Causes the command to behave like - thus, after deleting a message, the next one is typed automatically.
debug Causes to output information useful for debugging Setting the binary option debug is the same as specifying on the command
line.
dot Causes to interpret a period alone on a line as the terminator of a message you are sending.
hold Holds messages in the system mailbox by default.
ignore Causes interrupt signals from your terminal to be ignored and echoed as at signs (@).
ignoreeof Causes to refuse to accept a control-d as the end of a message.
msgprompt Prompts you for the message text and indicates how to terminate the message.
metoo Includes the sender in the distribution group receiving a mail message.
nosave Prevents from copying aborted messages into the dead.letter file in your home directory.
quiet Suppresses the printing of the version when first invoked.
verbose Displays the details of each message's delivery on the user's terminal. Setting the option is the same as typing -v on the
command line.
The string options include the following:
EDITOR Pathname of the text editor to use in the command and ~e escape. If not defined, then a default editor is used.
SHELL Pathname of the shell to use in the ! command and the ~! escape. A default shell is used if this option is not defined.
VISUAL Pathname of the text editor to use in the command and ~v escape.
crt Threshold to determine how long a message must be before is used to read it.
escape The first character of this option gives the character to use in the place of tilde (~) to denote escapes, if defined.
folder Directory name to use for storing folders of messages. If this name begins with a backslash (/) considers it an absolute
pathname; otherwise, the folder directory is found relative to your home directory.
record Pathname of the file used to record all outgoing mail. If it is not defined, then outgoing mail is not so saved.
toplines The number of lines of a message that is printed out with the top command; normally, the first five lines are printed.
Return Values
If mail is invoked with the -e option, the following exit values are returned:
0 the user has mail
1 the user has no mail
Files
/usr/spool/mail/* mail directory
~/mbox your read mail
~/.mailrc file giving initial mail commands
/tmp/R# temporary for editor escape
/usr/lib/Mail.help* help files
/usr/lib/Mail.rc system initialization file
Message* temporary for editing messages
See Also
binmail(1), fmt(1), newaliases(1), aliases(5), mailaddr(7), sendmail(8)
mail(1)