mail - send or read mail


mail [-e] [-f file]

mail name ...


You can use the mail(1) utility to read or send mail messages. It is a minimal environment.

To read mail, invoke mail(1) without any arguments. The mail(1) utility opens your mailfile (or the mailfile specified with the -f option). The default mailfile is /var/mail/name, where name is your login name, including your domain name. Additional commands available during mail reading sessions are described in this topic.

To send mail, invoke mail(1) with the name of a user as the operand. The mail(1) utility then takes standard input up to the end of file or a line consisting of only a dot character (.) and adds it to the mailfile of the user name.

The mail(1) command takes the following options:

Test for new mail, but display nothing. Exits with success if there is mail present, failure if there is not.
-f file
Read mail from the specified file instead of from the default mailbox.

On startup, the mail(1) utility reads the startup file /etc/mail.rc, which contains commands (as documented in the mailx(1) reference page). It then reads the startup file $HOME/.mailrc.

Mail reading commands

The mail(1) utility accepts the following commands:

Go on to next message.
Store undeleted mail and quit.
Execute the named command in the shell.
Go on to next message (same as newline).
Go back to previous message.
Delete the message and go on to the next message.
Mail the message to one or more users named name; if no user is specified, the message is mailed to the user who invoked mail(1).
Display message again.
Store undeleted mail and quit; same as end-of-file (EOF).
Save the message in file. If no file is named, save it in the file ~/mbox.
Save the message without its headers in file. If no file is named, save it in the file ~/mbox.
Exit mail(1), undoing all changes to the mailfile in this session. Put all mail back in the mailfile and stop.


The mail(1) command can exit with one of the following:

The user had mail and the session completed successfully.
The user had no mail or there was an initialization error.
An error occurred after initialization.


The mail(1) command makes use of the following environment variables, if set:

The user's home directory.
The current time zone; used in determining the setting of certain date and time strings.


The mail(1) utility makes use of the following files:

Default mailbox file.
Default storage location for read mail messages.


The mail(1) and the mailx(1) commands are the same image. If invoked as mail(1), it behaves as mail(1); if invoked as mailx(1), it behaves as mailx(1). When invoked as mail(1), it ignores the contents of the mailx(1) startup files (/etc/mailx.rc and $HOME/.mailrc).

The mail(1) command by itself has no ability to send mail to users on other hosts on the network. That requires a mail routing agent and a mail transfer agent, neither of which is provided with Interix.

The mail(1) command is actually the mailx(1) command; if invoked as mail(1), it behaves as described on this page.

In all other ways, mail(1) behaves as though it were mailx(1) with the following options set:

Abort the current letter on one interrupt rather than two.
Replace the dead.letter files instead of appending to them.
Try to save the dead.letter file in the current directory rather than in the home directory.
set dot
End message entry on a dot character (.) instead of a tilde (~).
set escape=
Disable tilde (~) escapes.
set noheader
Do not print a message summary on startup.
set quiet
Do not print other messages on startup.

See the mailx(1) reference page for more details.