MAIL(1)

NAME
mail, rmail - send mail to users or read mail

SYNOPSIS
mail [ -rpq ] [ -f file ] [ -s subject ] [ -u user ]

mail [ -g group ] persons

rmail persons

DESCRIPTION
Mail without arguments prints a user's mail, in last-in, first-out order. For large letters a paging routine is used. The user will be prompted with "-- more --"; hitting the SPACE key will continue the printing of the mail, one CRT page at a time. A q will terminate the paging. The user is then prompted and a line is read from the standard input to determine the disposition of the letter. The text of the prompt itself is composed of the following:

new mail arrived
    if present, indicates that new mail has arrived while the user has been interacting with mail.

EOF if present, indicates that an action on the last letter has been taken.

unpositioned
    if present, indicates that the user is not currently positioned on a letter.

last
    if present, indicates that the current letter is the last one in the mailfile.

nnn indicates the number nnn of the current letter.

?   end of prompt string.

Any one of the following commands can be entered to indicate the disposition of the current letter:

nnn Go on to letter number nnn.

RETURN
    Go on to next letter.

+   Same as RETURN.

d   Delete letter and go on to next letter.

dq  Delete letter, put undeleted mail back in mailfile, and stop.

u   Undelete letter and remain positioned on the letter.

p   Print current letter.

p|command
    Like the p command, but the letter is printed by passing it as standard input to the specified shell command. If the | is doubled, as in p||, the previous shell command is substituted. This procedure can be used to get a hard copy of a letter by typing p|lpr.

-   Go back to previous letter.

<   Go back to previous undeleted letter.

>   Advance to next undeleted letter.

s [ file ]
    Save (append) letter in the named file ($HOMEmbox is default). Standard shell syntax is allowed in file names (e.g., $PLACEfilename). If the file is not writable or if the expanded file name is ambiguous, then the user will be prompted for another file name. The letter is deleted from mailfile after being saved.

a   Answer a letter by sending a reply to the original sender. The original sender and the original subject is parsed from the "From " lines in the current letter. The subject of the new letter will have Re: prepended to the original subject. A In-Reply-To: message showing the date of the original letter is inserted after the subject. If the letter has been forwarded, then the answer is sent to the last person who forwarded the letter.

r   (reply) Same as a.

w [ file ]
    Save letter, without a header, in the named file ($HOMEmbox is default). The letter is not deleted from mailfile.

m [ -g groups ] [ persons ]
    Mail (forward) the letter to the named persons. A "forwarded by ..." message is inserted after the header.

M [ -g groups ] [ persons ]
    Mail the letter and a prepended comment to the named persons. The standard input is read through end-of-file for text or commands to prepend to the letter (see a command above). The body of the original letter is indented by '>'. A "forwarded by ..." annotation is inserted after the header.

l   List a table of contents of letters in the mailfile. Each letter is printed with its number, the date on which the letter was received, the identity of the sender, and the subject of the letter. The table of contents is ordered from newest to oldest, unless the -r option was specified, in which case the sort is reversed. A one-character disposition code is suffixed to the letter number if it has been deleted, forwarded, saved or answered. If the mailfile contains more than 18 letters, the table of contents is paginated with the same interface as pagination of long letters. Position on the first letter can be established by hitting the RETURN key.

h   (header) Same as l.

q   Put undeleted mail back in the mailfile and stop.

EOT (control-d) Same as q.

f   Put undeleted mail back in the mailfile and reopen the resulting mailfile. A new table of contents will be listed. This command is a handy response to the new mail arrived prompt. It avoids having to exit and reexecute mail.

x   Put all mail back in the mailfile unchanged and stop.

!command
    Escape to the shell to do command.

cd directory
    Change current working directory to directory. Standard shell syntax is allowed in directory names (e.g., $HOME/mail). If no directory is specified, $HOME is assumed by default. The directory remains the current working directory only for the duration of mail. If the -f option was used to specify an alternate mailfile that does not begin with /, the command is disallowed (because the wrong mailfile may be updated at exit).

cd! directory
    Same as cd, but the constraint on alternate mailfiles is lifted. (User beware!)

?   Print a command summary.

If a number is typed before the command, then that number is taken as the letter number. For example, the command '4d' typed at the prompt will delete letter number four no matter what number was being pointed to in the prompt string. This shortcut will work on the following commands: 'p', 'r', 'a', 'w', 's', 'm', 'M', 'd', and 'u'.

The optional command line arguments alter the printing or the sending of the mail.

-r  causes letter to be printed in first-in, first-out order.

-p  causes all mail to be printed without prompting for disposition.

-q  causes mail to terminate after interrupts. Normally an interrupt only causes the termination of the letter being printed.

-f file
    causes mail to use file instead of the default mailfile. If no file is specified, $HOME/mbox is assumed.

-s subject
    causes subject to be the subject of the outgoing mail.

-u user
    causes the mail of user to be read instead of the current user. The user's mailbox must be readable, or the current user must be root.

-g group
    causes mail to be sent to members of group that are designated in the file /etc/group.

When persons or groups are named, mail takes the standard input up to an end-of-file (or up to a line consisting of just a `.') and adds it to each person's or member's of the named group mailfile. An additional line of input is prompted by Cc: to determine an optional "Carbon Copy" distribution.

There are some input commands for interacting with a letter being entered:

~e  causes the text editor ed(1) to be invoked on the letter.

~v  causes the visual editor vi(1) to be invoked.

~p  causes the letter to be printed from the beginning to the current location.

~r file
    reads the named file into the letter.

~t [ -g groups ] [ persons ]
    Change the route list to the logins named by group and persons. If a % appears anywhere in the argument string, it is replaced by the previous list of addressees, as determined by the most recent specification. If no arguments are given, the current route list is printed.

~x  exits from the letter without changing anything. The letter is discarded and not sent.

~!  command causes the shell command line command to be executed.

~?  Print a command summary.

The letter is preceded by the sender's name and a postmark. Lines that look like postmarks in the letter, (i.e., ``From ...'') are prepended with `>'. An extra line showing the Cc: distribution is inserted after the normal To: line if that option was specified. A person is usually a user name recognized by login(1). However, mail will look first in the current user's $HOME/.alias file and finally in /etc/aliaslist for the named person. If the person is found, the translation found in the second column of the alias file will be used as the actual address. The alias file consists of two column entries separated by a tab. The first is the tag and the second is a comma separated list of translations. There is no rescan of the alias file for further (recursive) translations. If a person being sent mail is not recognized, or if mail is interrupted during input, the dead.letter will be saved to allow editing and resending. If a person is answering a letter, an interrupt saves the contents in a dead.answer file.

To denote a recipient on a remote system, prefix person by the system name and exclamation mark (see uucp(1C)). Everything after the first exclamation mark in persons is interpreted by the remote system. In particular, if persons contains additional exclamation marks, it can denote a sequence of machines through which the letter is to be sent on the way to its ultimate destination. For example, specifying sys1!sys2!login as a recipient's name causes the letter to be sent to user sys2!login on system sys1. System sys1 will interpret that destination as a request to send the letter to user login on system sys2. This might be useful, for instance, if the sending system can access system sys1 but not system sys2, and system sys1 has access to system sys2.

If the variable MAILLOG is defined in the environment and has a non-null value, it is assumed to be the name of a log file into which copies of all letters being sent by mail are kept. This includes letters being answered (a command) and forwarded (m and M commands).

The permissions of the mailfile file may be read-write, read-only, or neither read nor write to allow different levels of privacy. A mailfile that has default permissions will be unlinked when it becomes empty. However, if it has different permissions it is never unlinked in order to perpetuate file permissions.

The file may also contain the first line:
    Forward to person

which will cause all mail sent to the owner of the mailfile to be forwarded to person. This is especially useful to forward all of a person's mail to one machine in a multiple machine environment.

Rmail only permits the sending of mail. Uucp(1C) uses rmail as a security precaution.

Users are informed of the presence of mail, if any, when they log in.

FILES
/etc/passwd
    to identify sender and locate persons
/etc/group
    to identify members of groups
/usr/mail/*
    incoming mail for user *
$HOME/.alias
    to identify a user's list of alias'
/etc/aliaslist
    to identify a site's list of alias'
$HOME/mbox
    saved mail
$MAIL
    mailfile
$MAILLOG
    mail log file
/tmp/ma*
    temp file
/usr/mail/*.lock
    lock for mail directory
dead.letter
    unmailable text
dead.answer
    unmailable answer

SEE ALSO
login(1), uucp(1C), write(1),

BUGS
Race conditions sometimes result in a failure to remove a lock file. After an interrupt, the next letter may not be printed. Printing may be forced by responding p.

Mail does not handle mail items greater than 65535 characters long.

The mailfile has a tendency to go berserk.

The maximum number of letters that may be contained in a mailfile is 300 (a compile-time constant).

The ~t selection sometimes doesn't work.