The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group


mail - send or read mail (LEGACY)


mail [-e] [-f file]

mail [-e| -p][-qr][-f file]

mail [-t] name ...


The mail utility cannot guarantee support for all character encodings in all circumstances. For example, inter-system mail may be restricted to 7-bit data by the underlying network, 8-bit data need not be portable to non-internationalised systems, and so on. Under these circumstances, it is recommended that only characters defined in the ISO/IEC 646:1991 standard International Reference Version (equivalent to ASCII) 7-bit range of characters be used.
 Reading Mail
The mail utility without arguments writes a user's mail to standard output, message-by-message. Mail is stored in the user's individual mailfile. For each message, the user is given a prompt and a line is read from the standard input to determine the disposition of the message; see the EXTENDED DESCRIPTION section.
 Sending Mail
When names (user login names) are given, 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 user's mailfile. The message is preceded by the sender's name and a postmark. Lines in the message that begin with the sequence From are preceded with a ">".

If a user being sent mail is not recognised, or if mail is interrupted during input, the message is saved in the file dead.letter to allow editing and resending. Note that this is regarded as a temporary file in that it is recreated every time it is needed, erasing the previous contents of dead.letter. The mail utility tries to create dead.letter in the current directory. If that fails, it tries to create in the directory specified by the HOME environment variable.

It may also be possible to send mail to remote systems using system-specific naming conventions.

There are implementation-dependent mechanisms that can be used to cause all mail sent to the user to be forwarded to one or more other destinations.


The mail utility supports the XBD specification, Utility Syntax Guidelines  . The following options are supported for reading mail:
Test for the presence of mail. Display nothing and exit with a successful return code if there is mail to read.
Write all mail to standard output without prompting for disposition.
Terminate after interrupts. By default, an interrupt terminates only the message being written.
Write messages in first-in, first-out order.
-f file
Use file (for example, mbox) instead of the default mailfile.

The following option is supported for sending mail:

Precede the message by a list of all users the mail is sent to.


The following operand is supported for sending mail:
A user login name.


The standard input is a text file of commands for writing mail or a text file to be added to the user's mailfile when sending mail.




The following environment variable affects the execution of mail:
Determine the pathname of the user's home directory.

The following environment variables may affect the execution of mail:

Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
If set to a non-empty string value, override the values of all the other internationalisation variables.
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files).
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error, and informative messages written to standard output.
Determine the format and contents of date and time strings displayed by the mail utility.
Determine the location of message catalogues for the processing of LC_MESSAGES .
Determine the timezone used with date and time strings.


When reading mail, signals are caught and the user is returned immediately to the next prompt; however, if the -q option is specified, mail terminates. When sending mail, signals are caught, interrupting the user's input. Any text already input is saved in the file dead.letter.


When reading mail, the standard output is used for prompting and writing mail messages; the format of prompting and other informational messages is unspecified. When sending mail, the standard output is not used.


Used only for diagnostic messages.


When reading mail, messages can be appended to files designated by the s or w commands or to a user's mailfile by using the m command. When sending mail, messages are written to mailfiles or to dead.letter.


When reading mail, the following commands read from the standard input determine the disposition of messages:
Go on to next message.
Same as the newline character.
Delete message and go on to next message.
Display message again.
Go back to previous message.
Save the message in the named file (mbox is default).
Save the message (on some implementations, without its header) in the named file (mbox is default).
m[name ...]
Mail the message to the named users; the default is the user who invoked mail.
Store undeleted mail and stop.
Same as q.
Put all mail back in the mailfile unchanged and stop.
Escape to the command interpreter to execute command.
Display a command summary.


The following exit values are returned:
Successful completion when the user had mail.
The user had no mail or an initialisation error occurred.
An error occurred after initialisation.


When reading mail, the mailfile is unchanged. When sending mail, some of the named users need not have their mailfiles appended with the message.


Delivery of messages to remote systems requires the existence of communication paths to such systems. These need not exist.

The location of stored mail on exiting from mail using the q command differs between implementations and may be either the user's mailfile or the user's mbox.

In the description of reading mail, the phrase "go on to next message" might or might not imply the displaying of the next message.

Input lines are limited to {LINE_MAX} bytes, but mailers between systems may impose more severe line-length restrictions.

Applications should migrate to the mailx utility.






mailx, uuencode.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]