Linux and Unix mail and rmail command

Quick links

About mail and rmail
Syntax
User commands
Examples
Related commands
Linux and Unix main page

About mail and rmail

One of the ways that allows you to read/send E-Mail.

Syntax

Sending

mail [-t] [-w] [ -m message_type ] recipient ...

rmail [-t] [-w] [ -m message_type ] recipient ...

Reading

mail [-e] [-h] [-p] [-P] [-q] [-r] [ -f file ]

Debugging

mail [ -x debug_level ] [ other_mail_options ] recipient ...

-tA To: line is added to the message header for each of the intended recipients.
-wA letter is sent to a remote recipient without waiting for the completion of the remote transfer program.
-m message_typeA Message-Type: line is added to the message header with the value of message_type.
-eMail is not printed. An exit status of 0 is returned if the user has mail; otherwise, an exit status of 1 is returned.
-hA window of headers are initially displayed rather than the latest message. The display is followed by the ? prompt.
-pAll messages are printed without prompting for disposition.
-PAll messages are printed with all header lines displayed, rather than the default selective header line display.
-qmail terminates after interrupts. Normally an interrupt causes only the termination of the message being printed.
-rMessages are printed in first-in, first-out order.
-f filemail uses file (such as mbox) instead of the default mailfile.
-x debug_levelmail creates a trace file containing debugging information.

User command

#Display message number
-Print previous
+Next (no delete)
!commandEscape to the shell to execut command.
<CR>Next (no delete)
aPrint message that arrived during the mail session.
d or dpDelete the current message and print the next message.
d nDelete message number n. Do not go on to next message.
dqDelete message and quit mail.
hDisplay a window of headers around current message.
h nDisplay a window of headers around message number n.
h aDisplay headers of all messages in the user's mailfile.
h dDisplay headers of messages scheduled for deletion.
m [persons]Mail (and delete) the current message to the named persons.
nPrint message number n.
pPrint current message again, overriding any indications of binary (that is, unprintable) content.
POverride default brief mode and print current message again, displaying all header lines.
q, or CTRL-DPut undeleted mail back in the mailfile and quit mail .
r [users]Reply to the sender, and other users, then delete the message.
s [files]Save message in the named file s (mbox is default) and delete the message.
u [n]Undelete message number n (default is last read).
w [files]Save message contents, without any header lines, in the named files (mbox is default) and delete the message.
xPut all mail back in the mailfile unchanged and exit mail .
y [files]Same as -w option.
?Print a command summary.

Examples

mail

Opens the mail program with the first message in the mail (if applicable).

mail support@computerhope.com

Starts a new e-mail, sending the e-mail to the support at Computer Hope. When composing a message to terminate the message type a period ( . ) and press enter.

Related commands

chmod
csh
elm
login
mailx
pine