Linux mail command

Updated: 05/04/2019 by Computer Hope
mail command

On Unix-like operating systems, the mail command sends and receives e-mail.

This page covers the GNU/Linux version of mail.

Syntax

mail [OPTION...] [address...]

Options

-a, --append=HEADER: VALUE Append given header to the message being sent.
-e, --exist Return true if mail exists.
-E, --exec=COMMAND Execute COMMAND.
-f, --file[=URL] Operate on given mailbox URL. The default mailbox is ~/mbox.
-F, --byname Save messages according to sender.
-H, --headers Write a header summary and exit.
-i, --ignore Ignore interrupts.
-n, --norc Do not read the system mailrc file.
-N, --nosum Do not display initial header summary.
-p, --print Print all mail to standard output.
-q, --quit Cause interrupts to terminate program.
-r, --read Same as -p
-s, --subject=SUBJ Send a message with a subject of SUBJ.
-t, --to Precede message by a list of addresses.
-u, --user=USER Operate on USER's mailbox.
--license Print license and exit.
--external-locker=PATH Set full path of the external locker program
--lock-expire-timeout=SECONDS Number of seconds after which the lock expires.
--lock-flags=FLAGS Default locker flags (E=external, R=retry, T=time, P=pid)
--lock-retry-count=NUMBER Set the maximum number of times to retry acquiring the lockfile.
--lock-retry-timeout=SECONDS Set timeout for acquiring the lockfile.
-m, --mail-spool=URL Use specified URL as a mailspool directory.
--mailbox-type=PROTO Default mailbox type to use.
--tls[=BOOL] Enable TLS support.
-?, --help Display a help message and exit.
--usage Display a short usage message and exit.
-V, --version Display program version and exit.

Examples

mail

Opens the mail program and displays the first message in the mailbox, if any. If mail is found, the user is placed at a mail command prompt; type ? for a list of commands.

mail [email protected]

Starts a new e-mail addressed to [email protected]. When finished composing the message, type Ctrl-D on a new line.

How to read and send e-mail in a telnet or SSH session.

chmod — Change the permissions of files or directories.
csh — The C shell command interpreter.
elm — A mail client.
login — Begin a session on a system.
mailx — Process mail messages.
pine — A client for using mail and newsgroups.