up | Inhaltsverzeichniss | Kommentar

Manual page for MAIL(1)

mail, Mail - read or send mail messages

SYNOPSIS

Mail [ -deHinNUv ] [ -f [ filename | +folder ] ] [ -T file ] [ -u user ]

Mail [ -dFinUv ] [ -h number ] [ -r address ] [ -s subject ] recipient ...

/usr/ucb/mail ...

DESCRIPTION

mail is a comfortable, flexible, interactive program for composing, sending and receiving electronic messages. While reading messages, mail provides you with commands to browse, display, save, delete, and respond to messages. While sending mail, mail allows editing and reviewing of messages being composed, and the inclusion of text from files or other messages.

Incoming mail is stored in the system mailbox for each user. This is a file named after the user in /var/spool/mail. mail normally looks in this file for incoming messages, but you can use the MAIL environment variable to have it look in a different file. When you read a message, it is marked to be moved to a secondary file for storage. This secondary file, called the mbox, is normally the file mbox in your home directory. This file can also be changed by setting the MBOX environment variable. Messages remain in the mbox file until deliberately removed.

OPTIONS

If no recipient is specified, mail attempts to read messages from the system mailbox.

-d
Turn on debugging output. (Neither particularly interesting nor recommended.)
-e
Test for presence of mail. If there is no mail, mail prints nothing and exits (with a successful return code).
-F
Record the message in a file named after the first recipient. Override the record variable, if set.
-H
Print header summary only.
-i
Ignore interrupts (as with the ignore variable).
-n
Do not initialize from the system default Mail.rc file.
-N
Do not print initial header summary.
-U
Convert uucp style addresses to Internet standards. Overrides the conv environment variable.
-v
Pass the -v flag to sendmail.8
-f [filename]
Read messages from filename instead of system mailbox. If no filename is specified, the mbox is used.
-f +folder
Use the file folder in the folder directory (same as the folder command). The name of this directory is listed in the folder variable.
-h number
The number of network ``hops'' made so far. This is provided for network software to avoid infinite delivery loops.
-r address
Pass address to network delivery software. All tilde (~) commands are disabled.
-s subject
Set the Subject header field to subject.
-T file
Print the contents of the article-id fields of all messages that were read or deleted on file (for the use of network news programs if available).
-u user
Read user's system mailbox. This is only effective if user's system mailbox is not read protected.

USAGE

Refer to [a manual with the abbreviation GSBG] for tutorial information about mail.

Starting Mail

As it starts, mail reads commands from a system-wide file (/usr/lib/Mail.rc) to initialize certain variables, then it reads from a private start-up file called the .mailrc file (it is normally the file .mailrc in your home directory, but can be changed by setting the MAILRC environment variable) for your personal commands and variable settings. Most mail commands are legal inside start-up files. The most common uses for this file are to set up initial display options and alias lists. The following commands are not legal in the start-up file: !, Copy, edit, followup, Followup, hold, mail, preserve, reply, Reply, replyall, replysender, shell, and visual. Any errors in the start-up file cause the remaining lines in that file to be ignored.

You can use the mail command to send a message directly by including names of recipients as arguments on the command line. When no recipients appear on the mail command line, it enters command mode, from which you can read messages sent to you. If you list no recipients and have no messages, mail prints the message: `No mail for username' and exits.

When in command mode (while reading messages), you can send messages using the mail command.

Sending Mail

While you are composing a message to send, mail is in input mode. If no subject is specified as an argument to the command a prompt for the subject is printed. After entering the subject line, mail enters input mode to accept the text of your message to send.

As you type in the message, mail stores it in a temporary file. To review or modify the message, enter the appropriate tilde escapes, listed below, at the beginning of an input line.

To indicate that the message is ready to send, type a dot (or EOF character, normally CTRL-D ) on a line by itself. mail submits the message to sendmail.8 for routing to each recipient.

Recipients can be;

name@domain

[host!...host!]host!username

If the name of the recipient begins with a pipe symbol (|), the remainder of the name is taken as a shell command to pipe the message through. This provides an automatic interface with any program that reads the standard input, such as lpr.1 to record outgoing mail on paper. An alias group is the name of a list of recipients that is set by the alias command, taken from the host's /etc/aliases file, or taken from the Network Information Service (NIS) aliases domain. See aliases.5 for more information about mail addresses and aliases.

Tilde Escapes

The following tilde escape commands can be used when composing messages to send. Each must appear at the beginning of an input line. The escape character (~), can be changed by setting a new value for the escape variable. The escape character can be entered as text by typing it twice.
~! [shell-command]
Escape to the shell. If present, run shell-command.
~.
Simulate EOF (terminate message input).
~: mail-command
~_ mail-command
Perform the indicated mail command. Valid only when sending a message while reading mail.
~?
Print a summary of tilde escapes.
~A
Insert the autograph string Sign into the message.
~a
Insert the autograph string sign into the message.
~b name ...
Add the names to the blind carbon copy (Bcc) list. This is like the carbon copy (Cc) list, except that the names in the Bcc list are not shown in the header of the mail message.
~c name ...
Add the names to the carbon copy (Cc) list.
~d
Read in the dead.letter file. The name of this file is listed in the variable DEAD.
~e
Invoke the editor to edit the message. The name of the editor is listed in the EDITOR variable. The default editor is ex.1
~f [message-list]
Forward the listed messages, or the current message being read. Valid only when sending a message while reading mail; the messages are inserted without alteration (as opposed to the ~m escape).
~h
Prompt for the message header lines: Subject, To, Cc, and Bcc. If the header line contains text, you can edit the text by backspacing over it and retyping.
~i variable
Insert the value of the named variable into the message.
~m [message-list]
Insert text from the specified messages, or the current message, into the letter. Valid only when sending a message while reading mail; the text the message is shifted to the right, and the string contained in the indentprefix variable is inserted as the leftmost characters of each line. If indentprefix is not set, a TAB character is inserted into each line.
~p
Print the message being entered.
~q
Quit from input mode by simulating an interrupt. If the body of the message is not empty, the partial message is saved in the dead.letter file.
~r filename
~< filename
~<! shell-command
Read in text from the specified file or the standard output of the specified shell-command.
~s subject
Set the subject line to subject.
~t name ...
Add each name to the list of recipients.
~v
Invoke a visual editor to edit the message. The name of the editor is listed in the VISUAL variable. The default visual editor is vi.1
~w filename
Write the message text onto the given file, without the header.
~x
Exit as with ~q but do not save the message in the dead.letter file.
~| shell-command
Pipe the body of the message through the given shell-command. If shell-command returns a successful exit status, the output of the command replaces the message.

Reading Mail

When you enter command mode in order to read your messages, mail displays a header summary of the first several messages, followed by a prompt for one of the commands listed below. The default prompt is the & (ampersand character).

Message are listed and referred to by number. There is, at any time, a current message, which is marked by a > in the header summary. For commands that take an optional list of messages, if you omit a message number as an argument, the command applies to the current message.

A message-list is a list of message specifications, separated by SPACE characters, which may include:

.
The current message.
n
Message number n.
^
The first undeleted message.
$
The last message.
+
The next undeleted message.
-
The previous undeleted message.
*
All messages.
n-m
An inclusive range of message numbers.
user
All messages from user.
/string
All messages with string in the subject line (case ignored).
:c
All messages of type c, where c is one of:
d
deleted messages
n
new messages
o
old messages
r
read messages
u
unread messages

Note: the context of the command determines whether this type of message specification makes sense.

Additional arguments are treated as strings whose usage depends on the command involved. Filenames, where expected, are expanded using the normal shell filename-substitution mechanism.

Special characters, recognized by certain commands, are documented with those commands.

Commands

While in command mode, if you type in an empty command line (a RETURN or NEWLINE only), the print command is assumed. The following is a complete list of mail commands:
! shell-command
Escape to the shell. The name of the shell to use is listed in the SHELL variable.
# arguments
Null command. This may be used as if it were a comment in .mailrc files, but note that it must be separated from its arguments (commentary) by white space.
=
Print the current message number.
?
Print a summary of commands.
alias [alias recipient...]
group [alias recipient...]
Declare an alias for the given list of recipients. The list will be substituted when the alias is used as a recipient while sending mail. When put in the .mailrc file, this command provides you with a record of the alias. With no arguments, the command displays the list of defined aliases.
alternates name ...
Declare a list of alternate names for your login. When responding to a message, these names are removed from the list of recipients for the response. With no arguments, alternates prints the current list of alternate names.
cd[ directory]
chdir [directory]
Change directory. If directory is not specified, $HOME is used.
copy [message-list] [filename]
Copy messages to the file without marking the messages as saved. Otherwise equivalent to the save command.
Copy [message-list]
Save the specified messages in a file whose name is derived from the author of the message to be saved, without marking the messages as saved. Otherwise equivalent to the Save command.
delete [message-list]
Delete messages from the system mailbox. If the variable autoprint is set, print the message following the last message deleted.
discard [header-field...]
ignore [header-field...]
Suppress printing of the specified header fields when displaying messages on the screen, such as ``Status'' and ``Received''. The fields are included when the message is saved unless the variable alwaysignore is set. The Print and Type commands display all header fields, ignored or not.
dp [message-list]
dt [message-list]
Delete the specified messages from the system mailbox, and print the message after the last one deleted. Equivalent to a delete command followed by a print command.
echo [string ...]
Echo the given strings (like echo.1v
edit [message-list]
Edit the given messages. The messages are placed in a temporary file and the EDITOR variable is used to get the name of the editor. The default editor is ex.1
exit
xit
Exit from mail without changing the system mailbox. No messages are saved in the mbox (see also quit).
file [filename]
folder [filename]
Quit from the current mailbox file and read in the named mailbox file. Several special characters are recognized when used as file names:
%
Your system mailbox.
%user
The system mailbox for user.
#
The previous mail file.
&
Your mbox file (of messages previously read).
+filename
The named file in the folder directory (listed in the folder variable).

With no arguments, file prints the name of the current mail file, and the number of messages and characters it contains.

folders
Print the name of each mail file in the folder directory (listed in the folder variable).
followup [message]
Respond to a message, recording the response in a file, name of which is derived from the author of the message (overrides the record variable, if set). See also the Followup, Save, and Copy commands and the outfolder variable.
Followup [message-list]
Respond to the first message in the message list, sending the message to the author of each message in the list. The subject line is taken from the first message, and the response is recorded in a file, the name of which is derived from the author of the first message (overrides the record variable, if set). See also the followup, Save, and Copy commands and the outfolder variable.
from [message-list]
Print the header summary for the indicated messages or the current message.
group alias name ...
Same as the alias command.
headers [message]
Print the page of headers that includes the message specified, or the current message. The screen variable sets the number of headers per page. See also the z command.
help
Print a summary of commands.
hold [message-list]
preserve [message-list]
Hold the specified messages in the system mailbox.
if s|r|t
mail-command
...
else
mail-command
...
endif
Conditional execution, where s will execute following mail-command up to an else or endif, if the program is in send mode, r executes the mail-command only in receive mode, and t executes the mail-command only if mail is being run from a terminal. Useful primarily in the .mailrc file.
ignore [header-field...]
Same as the discard command.
inc
Incorporate messages that arrive while you are reading the system mailbox. The new messages are added to the message list in the current mail session. This command does not commit changes made during the session, and prior messages are not renumbered.
list
Prints all commands available. No explanation is given.
load [message] filename
Load the specified message from the name file. filename should contain a single mail message including mail headers (as saved by the save command).
mail recipient ...
Mail a message to the specified recipients.
mbox [message-list]
Arrange for the given messages to end up in the standard mbox file when mail terminates normally. See also the exit and quit commands.
new [message-list]
New [message-list]
unread [message-list]
Unread [message-list]
Take a message list and mark each message as not having been read.
next message
Go to next message matching message. A message-list can be given instead of message, but only first valid message in the list is used. (This can be used, for instance, to jump to the next message from a specific user.)
pipe [message-list] [shell-command]
| [message-list] [shell-command]
Pipe the message through shell-command. The message is treated marked as read (and normally saved to the mbox file when mail exits). If no arguments are given, the current message is piped through the command specified by the value of the cmd variable. If the page variable is set, a form feed character is inserted after each message.
preserve [message-list]
Same as the hold command.
print [message-list]
type [message-list]
Print the specified messages. If the crt variable is set, messages longer than the number of lines it indicates paged through the command specified by the PAGER variable. The default paging command is more.1
Print [message-list]
Type [message-list]
Print the specified messages on the screen, including all header fields. Overrides suppression of fields by the ignore and retain commands.
quit
Exit from mail storing messages that were read in the mbox file and unread messages in the system mailbox. Messages that have been explicitly saved in a file are deleted unless the variable keepsave is set.
reply [message-list]
respond [message-list]
replysender [message-list]
Send a response to the author of each message in the message-list. The subject line is taken from the first message. If record is set to a filename, a copy of the reply is added to that file. If the replyall variable is set, the actions of Reply/Respond and reply/respond are reversed. The replysender command is not affected by the replyall variable, but sends each reply only to the sender of each message.
Reply [message]
Respond [message]
replyall [message]
Reply to the specified message, including all other recipients of that message. If the variable record is set to a filename, a copy of the reply added to that file. If the replyall variable is set, the actions of Reply/Respond and reply/respond are reversed. The replyall command is not affected by the replyall variable, but always sends the reply to all recipients of the message.
retain
Add the list of header fields named to the retained list. Only the header fields in the retain list are shown on your terminal when you print a message. All other header fields are suppressed. The set of retained fields specified by the retain command overrides any list of ignored fields specified by the ignore command. The Type and Print commands can be used to print a message in its entirety. If retain is executed with no arguments, it lists the current set of retained fields.
save [message-list] [filename]
Save the specified messages in the named file. The file is created if it does not exist. If no filename is specified, the file named in the MBOX variable is used, mbox in your home directory by default. Each saved message is deleted from the system mailbox when mail terminates unless the keepsave variable is set. See also the exit and quit commands.
Save [message-list]
Save the specified messages in a file whose name is derived from the author of the first message. The name of the file is taken from the author's name, with all network addressing stripped off. See also the Copy, followup, and Followup commands and the outfolder variables.
set [variable[=value]]
Define a variable. To assign a value to variable, separate the variable name from the value by an `=' (there must be no space before or after the `='). A variable may be given a null, string, or numeric value. To embed SPACE characters within a value enclose it in quotes.

With no arguments, set displays all defined variables and any values they might have. See Variables for a description of all predefined mail variables.

shell
Invoke the interactive shell listed in the SHELL variable.
size [message-list]
Print the size in characters of the specified messages.
source filename
Read commands from the given file and return to command mode.
top [message-list]
Print the top few lines of the specified messages. If the toplines variable is set, it is taken as the number of lines to print. The default number is 5.
touch [message-list]
Touch the specified messages. If any message in message-list is not specifically saved in a file, it will be placed in the mbox upon normal termination. See also the exit and quit commands.
type [message-list]
Same as the print command.
Type [message-list]
Same as the Print command.
undelete [message-list]
Restore deleted messages. This command only restores messages deleted in the current mail session. If the autoprint variable is set, the last message restored is printed.
unread [message-list]
Unread [message-list]
Same as the new command.
unset variable ...
Erase the specified variables. If the variable was imported from the environment (that is, an environment variable or exported shell variable), it cannot be unset from within mail.
version
Print the current version and release date of the mail utility.
visual [message-list]
Edit the given messages with the screen editor listed in the VISUAL variable. The default screen editor is vi.1 Each message is placed in a temporary file for editing.
write [message-list] [filename]
Write the given messages onto the specified file, but without the header and trailing blank line. Otherwise, this is equivalent to the save command.
xit
Same as the exit command.
z[+|-]
Scroll the header display forward (+) or backward (-) one screenfull. The number of headers displayed is set by the screen variable.

Forwarding Messages

To forward a specific message, include it in a message to the desired recipients with the ~f or ~m tilde escapes. To forward mail automatically, add a comma-separated list of addresses for additional recipients to the .forward file in your home directory. This is different from the format of the alias command, which takes a space-separated list instead. Note: forwarding addresses must be valid (as described in aliases.5 or the messages will ``bounce.'' You cannot, for instance, reroute your mail to a new host by forwarding it to your new address if it is not yet listed in the NIS aliases domain.

Variables

The behavior of mail is governed by a set of predefined variables that are set and cleared using the set and unset commands.

Environment Variables

Values for the following variables are read in automatically from the environment; they cannot be altered from within mail:
HOME=directory
The user's home directory.
MAIL=filename
The name of the initial mailbox file to read (in lieu of the standard system mailbox). The default is /var/spool/mail/username.
MAILRC=filename
The name of the personal start-up file. The default is $HOME/.mailrc.

Mail Variables

The following variables can be initialized within the .mailrc file, or set and altered interactively using the set command. They can also be imported from the environment (in which case their values cannot be changed within mail). The unset command clears variables. The set command can also be used to clear a variable by prefixing the word no to the name of the variable to clear.

Variables for which values are normally supplied are indicated with an equal-sign (=). The equal-sign is required by the set command, and there can be no spaces between the variable-name, equal-sign, and value, using set to assign a value.

allnet
All network names whose last component (login name) match are treated as identical. This causes the message list specifications to behave similarly. Default is noallnet. See also the alternates command and the metoo variable.
alwaysignore
Ignore header fields with ignore everywhere, not just during print or type. Affects the save, Save, copy, Copy, top, pipe, and write commands, and the ~m and ~f tilde escapes.
append
Upon termination, append messages to the end of the mbox file instead of prepending them. Default is noappend but append is set in the global start-up file (which can be suppressed with the -n command line option).
askcc
Prompt for the Cc list after message is entered. Default is noaskcc.
asksub
Prompt for subject if it is not specified on the command line with the -s option. Enabled by default.
autoprint
Enable automatic printing of messages after delete and undelete commands. Default is noautoprint.
bang
Enable the special-casing of exclamation points (!) in shell escape command lines as in vi.1 Default is nobang.
cmd=shell-command
Set the default command for the pipe command. No default value.
conv=conversion
Convert uucp addresses to the address style specified by conversion, which can be either:
internet
This requires a mail delivery program conforming to the RFC822 standard for electronic mail addressing.
optimize
Remove loops in uucp.1c address paths (typically generated by the reply command). No rerouting is performed; mail has no knowledge of UUCP routes or connections.

Conversion is disabled by default. See also sendmail.8 and the -U command line option.

crt=number
Pipe messages having more than number lines through the command specified by the value of the PAGER variable (more by default). Disabled by default.
DEAD=filename
The name of the file in which to save partial letters in case of untimely interrupt or delivery errors. Default is the file dead.letter in your home directory.
debug
Enable verbose diagnostics for debugging. Messages are not delivered. Default is nodebug.
dot
Take a period on a line by itself during input from a terminal as EOF. Default is nodot but dot is set in the global start-up file (which can be suppressed with the -n command line option).
editheaders
Include message headers in the text to be edited by the ~e and ~v commands.
EDITOR=shell-command
The command to run when the edit or ~e command is used. Default is ex.1
escape=c
Substitute c for the ~ escape character.
folder=directory
The directory for saving standard mail files. User specified file names beginning with a plus (+) are expanded by preceding the filename with this directory name to obtain the real filename. If directory does not start with a slash (/), the value of HOME is prepended to it. There is no default for the folder variable. See also outfolder below.
header
Enable printing of the header summary when entering mail. Enabled by default.
hold
Preserve all messages that are read in the system mailbox instead of putting them in the standard mbox save file. Default is nohold for mail and hold for mailtool.1
ignore
Ignore interrupts while entering messages. Handy for noisy dial-up lines. Default is noignore.
ignoreeof
Ignore EOF during message input. Input must be terminated by a period (`.') on a line by itself or by the `~.' command. Default is noignoreeof. See also dot above.
indentprefix=string
When indentprefix is set, string is used to mark indented lines from messages included with ~m. The default is a TAB character.
keep
When the system mailbox is empty, truncate it to zero length instead of removing it. Disabled by default.
keepsave
Keep messages that have been saved in other files in the system mailbox instead of deleting them. Default is nokeepsave.
LISTER=shell-command
The command (and options) to use when listing the files in the folder directory. The default is ls.1v
MBOX=filename
The name of the file to save messages which have been read. The xit command overrides this variable, as does saving the message explicitly to another file. Default is the file mbox in your home directory.
metoo
If your login appears as a recipient, do not delete it from the list. Default is nometoo.
no
When used as a prefix to a variable name, has the effect of unsetting the variable.
onehop
When responding to a message that was originally sent to several recipients, the other recipient addresses are normally forced to be relative to the originating author's machine for the response. This flag disables alteration of the recipients' addresses, improving efficiency in a network where all machines can send directly to all other machines (that is, one ``hop'' away).
outfolder
Locate the files used to record outgoing messages in the directory specified by the folder variable unless the pathname is absolute. Default is nooutfolder. See folder above and the Save, Copy, followup, and Followup commands.
page
Used with the pipe command to insert a form feed after each message sent through the pipe. Default is nopage.
PAGER=shell-command
The command to use as a filter for paginating output, along with any options to be used. Default is more.1
prompt=string
Set the command mode prompt to string. Default is `&'.
quiet
Refrain from printing the opening message and version when entering mail. Default is noquiet.
record=filename
Record all outgoing mail in filename. Disabled by default. See also the variable outfolder.
replyall
Reverse the effect of the reply and Reply commands.
save
Enable saving of messages in the dead.letter file on interrupt or delivery error. See DEAD for a description of this file. Enabled by default.
screen=number
Set the number of lines in a screen-full of headers for the headers command.
sendmail=shell-command
Alternate command for delivering messages. Note: in addition to the expected list of recipients, mail also passes the -i and -m, flags to the command. Since these flags are not appropriate to other commands, you may have to use a shell script that strips them from the arguments list before invoking the desired command.
sendwait
Wait for background mailer to finish before returning. Default is nosendwait.
SHELL=shell-command
The name of a preferred command interpreter. Typically inherited from the environment, the shell is normally the one you always use. Otherwise defaults to sh.1
showto
When displaying the header summary and the message is from you, print the recipient's name instead of the author's name.
sign=autograph
The autograph text inserted into the message when the ~a (autograph) command is given. No default (see also the ~i tilde escape).
Sign=autograph
The autograph text inserted into the message when the ~A command is given. No default (see also the ~i tilde escape).
toplines=number
The number of lines of header to print with the top command. Default is 5.
verbose
Invoke sendmail with the -v flag.
VISUAL=shell-command
The name of a preferred screen editor. Default is vi.

FILES

$HOME/.mailrc
personal start-up file
$HOME/.forward
list of recipients for automatic forwarding of messages
$HOME/mbox
secondary storage file
$HOME/dead.letter
undeliverable messages file
/var/spool/mail
directory for system mailboxes
/usr/lib/Mail.help*
help message files
/usr/lib/Mail.rc
global start-up file
/tmp/R[emqsx]*
temporary files

SEE ALSO

biff.1 bin-mail.1 echo.1v ex.1 fmt.1 ls.1v mailtool.1 more.1 sh.1 uucp.1c vacation.1 vi.1 aliases.5 newaliases.8 sendmail.8

[a manual with the abbreviation GSBG]

mail is found in /usr/ucb/Mail, as a link to /usr/ucb/mail. If you wish to use the original (version 7) UNIX mail program, you can find it in /usr/bin/mail. Its man page is named bin-mail.1

BUGS

Where shell-command is shown as valid, arguments are not always allowed. Experimentation is recommended.

Internal variables imported from the execution environment cannot be unset.

Replies do not always generate correct return addresses. Try resending the errant reply with onehop set.

mail does not lock your record file. So, if you use a record file and send two or more messages simultaneously, lines from the messages may be interleaved in the record file.

The format for the alias command is a space-separated list of recipients, while the format for an alias in either the .forward or /etc/aliases is a comma-separated list.

NOTES

The Network Information Service (NIS) was formerly known as Sun Yellow Pages (YP). The functionality of the two remains the same; only the name has changed.


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97