MAIL(1) — Unix Programmer’s Manual
NAME
mail − send and receive mail
SYNOPSIS
mail [ −v ] [ −i ] [ −n ] [ −s subject ] [ users ]
mail [ −v ] [ −i ] [ −n ] −f [ name ]
mail [ −v ] [ −i ] [ −n ] −u user
DESCRIPTION
Mail is an intelligent mail processing system which has a command syntax reminiscent of ed, with lines replaced by messages.
Sending Mail: To send a message to one or more people, the user enters mail followed by the names of the recipients. The user then types in the message, and terminates it by entering by an EOT (CTRL-D) at the beginning of a line. A subject may be specified on the command line by using the −s flag. (Only the first argument after the −s flag is used as a subject; subject text containing embedded blanks should be enclosed in quotation marks.) A section below, “Replying To or Originating Mail,” describes some features of mail which can help the user compose a letter.
Reading Mail: In normal usage mail is given no arguments. It checks out the user’s mail from the post office, then prints a one line header of each message. The current message is initially the first message (numbered 1) and can be printed using the print command (which can be abbreviated p). The user can move among the messages much as one moves between lines in ed, using the commands + and − to move backwards and forwards, and simple numbers to go directly to a particular message.
Disposing of Mail: After examining a message, the user 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 mail session can be aborted by giving the exit (x) command. Deleted messages, however, will usually disappear—never to be seen again.
Specifying Messages: Commands such as print and delete can be given a list of message numbers as arguments to apply to several messages at once. Thus delete 1 2 deletes messages 1 and 2, while delete 1−5 deletes messages 1 through 5. The special name ∗ addresses all messages, and $ addresses the last message; thus the command top, which prints the first few lines of a message, could be used in top ∗ to print the first few lines of all messages.
Replying To or Originating Mail: The reply command can be used to respond to a message. The user enters r, then types in the text of the reply, up to an end-of-file. At that point, the reply is sent to the originator of the initial message. While the user is composing a message, mail gives special treatment to lines beginning with the character ~ . For instance, typing ~m alone on a line will place a copy of the current message into the response, right-shifting it by a tabstop. Other escapes will set up subject fields, add and delete recipients to the message and allow the user to escape to an editor in order to revise the message, or escape to a shell to run some commands. (These options are given in the summary below.)
Ending a Mail Processing Session: The mail session is ended with the quit (q) command. Messages which have been examined go to the user’s “mbox” file. Those which have been deleted are discarded. Unexamined messages go back to the post office. The −f option causes mail to read in the contents of mbox (or the specified file) for processing; when the user issues a quit, the mail program writes undeleted messages back to this file. The −u flag is a short form of the command mail −f /usr/spool/mail/user .
Personal and System Wide Distribution Lists: Personal distribution lists can be created so that, for example, a user can address mail to “cohorts” and have the message go to a specified group of people. Such lists can be defined by placing a line like the following in the “.mailrc” file in the sender’s home directory:
alias cohorts bill ozalp jkf mark kridle@ucbcory
The current list of such aliases can be displayed with the alias (a) command in mail. System wide distribution lists can be created by editing /usr/lib/aliases (see aliases(5) and sendmail(8)); these are kept in a different syntax. Personal aliases will then be expanded in mail the user sends to others, so that others will be able to reply to the recipients. 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.
Network Mail (ARPA, UUCP, Berknet): See mailaddr(7) for a description of network addresses.
Mail has a number of options which can be set in the .mailrc file to alter its behavior; thus, for example, set askcc enables the askcc feature. These options are summarized below.
COMMANDS
(Adapted from the Mail Reference Manual.)
Each command is typed on a line by itself, and may take arguments following the command word. The command need not be typed in its entirety: the first command which matches the typed prefix is used. For commands which 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 terminal terminate termini terminology terminus termite tern ternary Terpsichore terpsichorean Terra terrace terrain terramycin terrapin Terre terrestrial terrible terrier terrific terrify territorial territory terror terry terse tertiary Tess tessellate test testament testamentary testate testes testicle testicular testify testimonial testimony testy tetanus tete tether tetrachloride tetrafluouride tetragonal tetrahedra tetrahedral tetrahedron tetravalent Teutonic Texaco Texan Texas texh proceeds backwards. If there are no appropriate messages at all, mail prints “No applicable messages” and aborts the command.
− Prints out the previous message. If given a numeric argument n, it prints the nth previous message.
? Prints a brief summary of commands.
! Executes the UNIX shell command which follows.
alias (a) With no arguments, prints out all currently-defined aliases. With one argument, prints out that alias. With more than one argument, creates a new alias or changes an old alias.
alternates (alt) Convenient for a user with accounts on several machines. Used to inform mail that the listed addresses all apply to the same user. When this user employs reply, mail will not send a copy of the message to any of the addresses on the alternates list. If the alternates command is given with no argument, the current set of alternate names is displayed.
chdir (c) Changes the user’s working directory to the specified directory. If no directory is given, then changes to the user’s login directory.
copy (co) Same as save, except that copy does not mark for deletion the messages on which it is used.
delete (d) Takes a list of messages as argument and marks them all as deleted. Deleted messages will not be saved in mbox, nor will they be available for most other commands.
dp (also dt) Deletes the current message and prints the next one. If there are no further messages, the text “At EOF” is displayed.
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 returned to storage, as changed.
exit (ex or x) Returns immediately to the shell without modifying the user’s system mailbox, mbox file, or edit file in −f.
file (fi) Same as folder.
folders Lists the names of the folders in the user’s folder directory.
folder (fo) The folder command switches to a new mail file or folder. With no arguments, it names the file currently being read. With an argument, it writes out changes (such as deletions) made in the current file, and reads in the new file. Special conventions are recognized for the name:
# the previous file
% the user’s system mailbox
%userthe user’s system mailbox
& the user’s ~/mbox file
+foldera file in the user’s folder directory
from (f) Prints the headers of a list of messages.
headers (h) Lists the current range of headers, which is an 18-message group. If the argument + is given, then the next 18-message group is printed; if the argument − is given, the previous 18-message group is printed.
help A synonym for ?
hold (ho, also preserve) Marks each message in a list to be saved in the user’s system mailbox rather than in mbox. Does not override the delete command.
ignore Adds the named list of header fields to the “ignore list.” Header fields in the ignore list are not displayed on the terminal when a message is printed. This command is very useful for suppression of certain machine-generated header fields. The Type and Print commands can be used to print a message in its entirety, including ignored fields. If ignore is executed with no arguments, it lists the current set of ignored fields.
mail (m) Takes as argument login names and distribution group names and sends mail to those people.
mbox Indicates that a list of messages should be sent to mbox in the user’s home directory when she or he quits. This is the default action for messages if the hold option is not set.
next (n, also + or CR) Prints the next message in sequence. With an argument list, prints the next matching message.
preserve (pre) A synonym for hold.
print (p) Prints on the user’s terminal each message in a message list.
Print (P) Similar to print but also displays ignored header fields. See also ignore.
quit (q) Terminates the session, saving all undeleted, unsaved messages in the user’s mbox file in his or her login directory, preserving all messages marked with hold or preserve or never referenced in the user’s system mailbox, and removing all other messages from the user’s system mailbox. If new mail has arrived during the session, the message “You have new mail” is given. If given while editing a mailbox file with the −f flag, then the edit file is rewritten. A return to the shell is effected, unless the rewrite of edit file fails, in which case the user can escape with the exit command.
reply (r) Sends mail to the sender and all recipients of the specified message. The default message must not be deleted.
Reply (R) Reply to originator. Does not reply to other recipients of the original message.
respond A synonym for reply.
save (s) Takes a message list and a filename and appends each message in turn to the end of the file. The filename in quotes, followed by the line count and character count, is echoed on 4he user’s terminal.
set (se) With no arguments, prints all variable values. Otherwise, sets option. Arguments are of the form option=value or option.
shell (sh) Invokes an interactive version of the shell.
size Displays the character count of each message on a message list.
source (so) Reads mail commands from a file.
top Prints the top few lines of each message on a message list. The number of lines printed is controlled by the variable toplines, and defaults to five.
type (t) A synonym for print.
Type (T) Identical to the Print command.
unalias Discards a list of names defined by alias commands. 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 set.
visual (v) Invokes the display editor on each message in a message list.
write (w) A synonym for save.
xit (x) A synonym for exit.
z Mail presents message headers a window at a time, as described under the headers command. The user can advance to the next window with the z command, and return to the previous window with the command z−.
ESCAPES
The following is a summary of the tilde escapes, which are used to perform special functions when composing messages. Tilde escapes are only recognized at the beginning of a line. The name “tilde escape” is rather a misnomer since the actual escape character can be set by the option escape.
~!command Executes the indicated shell command, then returns to the message.
~c names Adds the specified names to the list of carbon copy recipients.
~d Reads the file “dead.letter” from the home directory into the message.
~e Invokes the text editor on the message collected so far. After the editing session is finished, the user 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 Used to edit the message header fields. Prints each one in turn and allows 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 right one tab. If no messages are specified, reads the current message.
~p Prints out the message collected so far, prefaced by the message header fields.
~q Aborts the message being sent, copying it to dead.letter in the user’s home directory if save is set.
~r filename Reads the named file into the message.
~s string Causes the named string to become the current subject field.
~t names Adds the specified names to the direct recipient list.
~v Invokes an alternate editor (defined by the visual option) on the message collected so far. Usually, the alternate editor will be a screen editor. After quitting the editor, the user may continue appending text to the end of the 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 original 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 ~. If the user has changed the escape character, then she or he should double that character in order to send it.
OPTIONS
−i Causes tty interrupt signals to be ignored. This is particularly useful when using mail on noisy phone lines.
−n Inhibits the reading of /usr/lib/Mail.rc.
−v Puts mail into verbose mode; the details of delivery are displayed on the user’s terminal.
−f file Uses file instead of mailfile (“mbox” default).
−u name Reads name’s mail. (Same as mail −f /usr/spool/mail/name)
? Prints command summary, after mail prompt.
−s subj Places the entry “Subject: subj” at the start of the message.
BINARY OPTIONS
These options are controlled via the set and unset commands. They may be binary options or string options. With binary options, it is only significant to see whether or not they are set; with string options, the actual value is of interest. The binary options include the following:
append Causes messages saved in mbox vascular vase vassal vast vat Vatican vaudeville Vaudois Vaughan Vaughn vault veal vector vectorial Veda vee veer veery Vega vegetable vegetarian vegetate vehement vehicle vehicular veil vein Velasquez veldt Vella vellum velocity velours velvet velvety venal vend vendetta vendible vendor veneer venerable venerate venereal Venetian Veneto Venezuela vengeance vengeful venial Venice venison venom venomous vent ventilate ventricle venture venturesome venturi Venus Venusian Vera veracious veracityed. (This is set in /usr/lib/Mail.rc on version 7 systems.)
ask Prompts the user for the subject of each message being composed. If the user responds with simply a newline, no subject field is included.
askcc Prompts the user for additional carbon copy recipients at the end of each message. Entering a newline indicates satisfaction with the current list.
autoprint Causes the delete command to behave like dp. Thus, after a message is deleted the next one is printed automatically.
debug Same as specifying −d on the command line. Causes mail to output information useful for debugging mail.
dot Causes mail to interpret a period alone on a line as the terminator of a message being sent.
hold Preserves messages in the system mailbox by default.
ignore Causes interrupt signals from the terminal to be ignored and echoed as @ characters.
ignoreeof Related to dot. Makes mail refuse to accept CTRL-D as the end of a message. Ignoreeof also applies to mail command mode.
metoo When a group containing the sender is expanded, the sender is usually removed from the expansion. Setting this option causes the sender to be included in the group.
nosave Normally, when the user aborts a message with two RUBOUTs, mail copies it to the dead.letter file in the user’s home directory. Nosave can be used to prevent this.
quiet Suppresses printing of the version when first invoked.
verbose Same as using the −v flag on the command line. Informs the user as mail is received.
STRING OPTIONS
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 The value of crt is used as a threshold to determine how long a message must be before more is used to read it.
escape If defined, the first character of this option specifies the character to use in place of ~ to denote escapes.
folder Names the directory to use for storing folders of messages. If this name begins with / then mail considers it to be an absolute pathname; otherwise, the folder directory is found relative to the user’s home directory.
record If defined, gives the pathname of the file used to record all outgoing mail. If not defined, then outgoing mail is not saved in this manner.
4th Berkeley Distribution — 1 August 1985