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 ...

-t A To: line is added to the message header for each of the intended recipients.
-w A letter is sent to a remote recipient without waiting for the completion of the remote transfer program.
-m message_Type A Message-Type: line is added to the message header with the value of message_Type.
-e Mail is not printed. An exit status of 0 is returned if the user has mail; otherwise, an exit status of 1 is returned.
-h A window of headers are initially displayed rather than the latest message. The display is followed by the ? prompt.
-p All messages are printed without prompting for disposition.
-P All messages are printed with all header lines displayed, rather than the default selective header line display.
-q mail terminates after interrupts. Normally an interrupt causes only the termination of the message being printed.
-r Messages are printed in first-in, first-out order.
-f file mail uses file (such as mbox) instead of the default mailfile.
-x debug_level mail creates a trace file containing debugging information.

User command

# Display message number
- Print previous
+ Next (no delete)
!command Escape to the shell to execut command.
<CR> Next (no delete)
a Print message that arrived during the mail session.
d or dp Delete the current message and print the next message.
d n Delete message number n. Do not go on to next message.
dq Delete message and quit mail.
h Display a window of headers around current message.
h n Display a window of headers around message number n.
h a Display headers of all messages in the user's mailfile.
h d Display headers of messages scheduled for deletion.
m [persons] Mail (and delete) the current message to the named persons.
n Print message number n.
p Print current message again, overriding any indications of binary (that is, unprintable) content.
P Override default brief mode and print current message again, displaying all header lines.
q, or CTRL-D Put 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.
x Put 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