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

 NAME

mail - send or read mail (LEGACY)

 SYNOPSIS



mail [-e] [-f file]

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

mail [-t] name ...

 DESCRIPTION

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.

 OPTIONS

The mail utility supports the XBD specification, Utility Syntax Guidelines  . The following options are supported for reading mail:
-e
Test for the presence of mail. Display nothing and exit with a successful return code if there is mail to read.
-p
Write all mail to standard output without prompting for disposition.
-q
Terminate after interrupts. By default, an interrupt terminates only the message being written.
-r
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:

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

 OPERANDS

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

 STDIN

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.

 INPUT FILES

None.

 ENVIRONMENT VARIABLES

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

The following environment variables may affect the execution of mail:

LANG
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.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
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).
LC_MESSAGES
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.
LC_TIME
Determine the format and contents of date and time strings displayed by the mail utility.
NLSPATH
Determine the location of message catalogues for the processing of LC_MESSAGES .
TZ
Determine the timezone used with date and time strings.

 ASYNCHRONOUS EVENTS

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.

 STDOUT

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.

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

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.

 EXTENDED DESCRIPTION

When reading mail, the following commands read from the standard input determine the disposition of messages:
newline
Go on to next message.
+
Same as the newline character.
d
Delete message and go on to next message.
p
Display message again.
-
Go back to previous message.
s[file]
Save the message in the named file (mbox is default).
w[file]
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.
q
Store undeleted mail and stop.
<EOF>
Same as q.
x
Put all mail back in the mailfile unchanged and stop.
!command
Escape to the command interpreter to execute command.
*
Display a command summary.

 EXIT STATUS

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

 CONSEQUENCES OF ERRORS

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

 APPLICATION USAGE

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.

 EXAMPLES

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

mailx, uuencode.

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