MAIL(1)
NAME
mail − send and receive mail
USAGE
mail [ −v ] [ −i ] [ −n ] [ −s subject ] [ user ... ]
mail [ −v ] [ −i ] [ −n ] −f [ name ]
mail [ −v ] [ −i ] [ −n ] −u user
DESCRIPTION
Mail is an intelligent mail processing system, similar in command syntax to ed (1), with lines replaced by messages. Note that information about this command refers to /usr/ucb/Mail, and should not be confused with /bin/mail, which is documented under the binmail (1) command.
To send a message to one or more people, you can invoke mail with arguments that are the names of designated recipients. You then type your message, followed by an EOF (usually ↑Z) at the beginning of a line. If you wish, you may specify a subject on the command line.
When you wish to read messages sent to you, mail prints out a one-line header of each message there. The current message is initially the first message (numbered 1) and can be printed using the print command (abbreviated as p). You can move among the messages much as you move between lines in ed (1), with a plus sign (+) to move forward and a minus sign (−) to move backward. If you use these, and also specify a simple number, you can move forward or backward that number of messages.
After examining a message, you can delete (d) the message or reply (r) to it. Deletion causes the mail program to forget about the message. This is not irreversible; the message can be undeleted (u) by giving its number, or the session can be aborted by giving the exit (x) command. Deleted messages usually disappear, however.
Commands such as print and delete can be given a list of message numbers as arguments to apply to a number of messages at once. Thus, delete 1 2 deletes messages 1 and 2, while delete 1−5 deletes messages 1 through 5. The asterisk (*) is a special character that addresses all messages. The dollar sign ($) is a special character that addresses the last message. Thus, you can use the top command, which prints the first few lines of a message, as top * to print the first few lines of all messages.
To respond to the originator of a message, use the reply command. Text you then type in, up to an end-of-file, defines the contents of the message. While you are composing a message, mail treats lines beginning with a tilde (~) specially. For instance, typing ~m alone on a line places a copy of the current message into the response right shifting it by a tabstop. Other escapes set up subject fields, add and delete recipients to the message, and allow you to escape to an editor to revise the message or to a Shell to run some commands.
To end a mail session, use the quit (q) command. Messages that have been examined go to your mbox file, unless they have been deleted. Unexamined messages go back to the post office.
It is also possible to create a personal distribution list so that, for instance, you can send mail to a group of people. Such lists can be defined by placing a line like the following in the .mailrc file in your home directory:.
alias cohorts bill larry sue
To display the current list of such aliases, use the alias (a) command in mail. You can create system-wide distribution lists by editing /usr/lib/aliases. Refer to aliases (5) and sendmail (8); these are kept in a different syntax. Personal aliases are expanded in mail sent to others so that recipients can reply. 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 sendmail (8).
Network mail (ARPA, UUCP, Berknet) is another possibility. See mailaddr (5) for a description of network addresses.
Mail has a number of options that you can use to alter its behavior. You set these options in the .mailrc file by using the set command. Thus, set askcc enables the askcc feature.
COMMANDS
Each command should appear on a separate line, with arguments following the command word. You can either use the entire command name, or its valid prefix. If a command normally takes a message list as an argument, and you have specified none, the next message forward that satisfies the command’s requirements is used. If there are no messages forward of the current message, the search proceeds backwards, and if there are no good messages at all, mail responds with “No applicable messages” and aborts the command.
− Print the previous message. If given a numeric argument n, go to the nth previous message and print it.
? Print a brief summary of commands.
! Execute the UNIX Shell command that follows.
Print (P) Perform the same function as print, but also print out ignored header fields. See also print and ignore.
Reply (R) Reply to originator. Do not reply to other recipients of the original message.
Type (T) Perform the same function as the Print command.
alias (a) With no arguments, print out all currently-defined aliases. With one argument, print out that alias. With more than one argument, create an new alias or change an old alias.
alternates (alt)
Inform mail that the listed addresses are really you. When you reply to messages, mail does not send a copy of the message to any of the addresses listed on the alternates list. If the alternates command is given with no argument, the current set of alternate names is displayed. The alternates command is useful if you have accounts on several machines.
chdir (c) Change your working directory to the one specified. If no directory is named, then change to your log-in directory.
copy (co) Perform the same function as the save command, but do not mark the current messages as ones to be deleted when the mail session is over.
delete (d) Take a list of messages as an argument and mark them all as deleted. Do not save deleted messages in mbox, nor make them available for most other commands.
dp Delete the current message and print the next one. If there is no next message, respond with “at EOF.”
dt Perform the same function as the dp command.
edit (e) Take a list of messages and point the text editor at each one in turn. On return from the editor, read the message back in.
exit (ex or x)
Return to the Shell immediately, without modifying your system mailbox, mbox file, or edit file in −f.
file (fi) Perform the same function as folder.
folders List the names of the folders in your folder directory.
folder (fo) Switch to a new mail file or folder. With no arguments, identify which file you are currently reading. With an argument, write out changes (e.g., deletions) made in the current file, and read in the new file. A pound sign (#) means the previous file, a percent sign (%) means your system mailbox, a percent sign with a user name (%user) means user’s system mailbox, an ampersand (&) means your ~/mbox file, and a plus sign with the word “folder” added (+folder) means a file in your folder directory.
from (f) Take a list of messages and print their message headers.
headers (h) List the current range of headers, which is an 18-message group. If a plus sign (+) argument is given, print the next 18-message group; if a minus (−) argument is given, print the previous 18-message group.
help Provide help on mail. This is a synonym for the question mark (?) character.
hold (ho) Take a message list and mark each message therein to be saved in your system mailbox instead of in mbox. Do not override the delete command.
ignore Add the list of header fields named to the ignored list. Do not print header fields in the ignore list on your terminal when you print a message. This command is very handy for suppression of certain machine-generated header fields. You can use the Type and Print commands to print a message in its entirety, including ignored fields. If you execute ignore with no arguments, it lists the current set of ignored fields.
mail (m) Send mail to those people specified in the log-in names and distribution group names given as arguments.
mbox Indicate that a list of messages be sent to mbox in your home directory when you quit. This is the default action for messages if you do not have the hold option set.
next (n) Go to the next message in sequence and type it. You can also use a plus sign (+) or a carriage return to do the same thing. With an argument list, this command prints the next matching message.
preserve (pre)
Perform the same function as the hold command.
print (p) Take a message list and type out each message on your terminal.
quit (q) Terminate the session, saving all undeleted, unsaved messages in the mbox file in your log-in directory, preserving all messages marked with hold or preserve or never referenced in your system mailbox, and removing all other messages from your system mailbox. If new mail has arrived during the session, you are notified with a “You have new mail” message. If given while you are editing a mailbox file with the −f flag, rewrite the edit file. Return to the Shell, unless the rewrite of the edit file fails, in which case escape with the exit command.
reply (r) Take a message list and send mail to the sender and all recipients of the specified message. Do not delete the default message.
respond Perform the same function as reply.
save (s) Take a message list and a filename and append each message in turn to the end of the file. Echo the filename in quotes, followed by the line count and character count.
set (se) With no arguments, print all variable values. Otherwise, set the option. Arguments are of the form option=value or option.
shell (sh) Invoke an interactive version of the Shell.
size Take a message list and print out the size (in characters) of each message.
source (so) Read mail commands from a file.
top Take a message list and print the top few lines of each. The number of lines printed is controlled by the variable toplines and defaults to five.
type (t) Perform the same function as print.
unalias Take a list of names defined by alias commands and discard the remembered groups of users. The group names no longer have any significance.
undelete (u)
Take a message list and mark each one as not being deleted.
unset Take a list of option names and discard their remembered values; do the inverse of set.
visual (v) Take a message list and invoke the display editor on each message.
write (w) Perform the same function as save.
xit (x) Perform the same function as exit.
z Move the attention of Mail forward to the next window. (Mail presents message headers in windowfuls as described under the headers command.) You can also move to the previous window by using z−.
TILDE ESCAPES
When you are composing messages to perform special functions, you need to use certain tilde (~) escapes. Tilde escapes are only recognized at the beginning of lines. The name tilde escape is somewhat of a misnomer, since the actual escape character can be set by the option escape.
~!command Execute the indicated Shell command, then return to the message.
~c name ... Add the given names to the list of carbon copy recipients.
~d Read the dead.letter file from your home directory into the message.
~e Invoke the text editor on the message collected so far. After the editing session is finished, you may continue appending text to the message.
~f messages Read the named messages into the message being sent. If no messages are specified, read in the current message.
~h Edit the message header fields by typing each one in turn. Allow text to be appended to the end, or the field to be modified, using the current terminal erase and kill characters.
~m messages
Read the named messages into the message being sent, shifted right one tab. If no messages are specified, read the current message.
~p Print out the message collected so far, prefaced by the message header fields.
~q Abort the message being sent, copying the message to the dead.letter file in your home directory (if save is set).
~r filename Read the named file into the message.
~s string Make the named string the current subject field.
~t name ... Add the given names to the direct recipient list.
~v Invoke an alternate editor on the message collected so far. Usually, the alternate editor is a screen editor. After you quit the editor, you may resume appending text to the end of your message.
~w filename Write the message onto the named file.
~|command Pipe the message through the command as a filter. If the command gives no output or terminates abnormally, retain the original text of the message. The fmt (1) command is often used as command to rejustify the message.
~~string Insert the string of text in the message prefaced by a single tilde (~). If you have changed the escape character, double that character so that it may be sent.
OPTIONS CONTROLLED BY SET AND UNSET
You control options by using the set and unset commands. Options may be either binary or string. For a binary option, you need only check to see whether it is set or not. For a string option, however, the actual value of the option is of interest. Binary options include the following:
append Append (rather than prepend) messages saved in mbox.
ask Prompt for the subject of each message being sent. If you respond with simply a newline, no subject field is sent.
askcc Prompt for additional carbon copy recipients at the end of each message. Responding with a newline indicates satisfaction with the current list.
autoprint Cause the delete command to behave like the dp command. Thus, after deleting a message, the next one is printed automatically.
debug Perform the same function as a −d on the command line, and output information useful for debugging mail.
dot Interpret a period alone on a line as the terminator of a message being sent.
hold Hold messages in the system mailbox by default.
ignore Ignore interrupt signals from the terminal, echoing them back as at sign (@) characters.
ignoreeof Refuse to accept an EOF as the end of a message. This option also applies to mail command mode.
metoo Include the sender in the group that is expanded. Usually, when a group containing the sender is expanded, the sender is removed from the expansion.
nosave Prevent the normal copying of a partial letter to the dead letter file in your home directory when you abort a message with two interrupts.
quiet Suppress the printing of the version when first invoked.
verbose Perform the same function as specifying a −v option on the command line. Display, on the terminal, the actual delivery of messages.
The following options have string values:
EDITOR Pathname of the text editor to use in the edit 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 visual command and ~v escape.
crt If defined, determines how long a message must be before more (1) is used to read it.
escape If defined, the first character of this option specifies the character to use in place of a tilde (~) to denote escapes.
folder The name of the directory to use for storing folders of messages. If this name begins with a slash (/), mail considers it to be an absolute pathname; otherwise, the folder directory is found relative to your home directory.
record If defined, gives the pathname of the file used to record all outgoing mail.
toplines If defined, gives the number of lines of a message to be printed out with the top command. Normally, the first five lines are printed.
COMMAND LINE OPTIONS
−v Display, on your terminal, the details of mail delivery.
−i Ignore TTY interrupt signals. This is particularly useful when accessing mail on noisy phone lines.
−n Inhibit the reading of /usr/lib/Mail.rc.
−s Specify a particular subject when sending mail. Only the first argument after the −s option is used as a subject. Make sure to quote subjects containing spaces.
−f Read in the contents of your mbox (or the specified file) for processing. Upon termination of the session, write undeleted messages back to this file.
−u Read in the contents of /usr/spool/mail/user for processing. Upon termination of the session, write undeleted messages back to this file.
FILES
/usr/spool/mail/*post office
~/mboxyour old mail
~/.mailrcfile giving initial mail commands
/tmp/R#temporary for editor escape
/usr/lib/Mail.help*help files
/usr/lib/Mail.rcsystem initialization file
Message*temporary for editing messages