mailx, Mail - Sends and receives mail
mailx [-dinvF] [-h number] [-r address] [-s subject] user...
Mail [-dinvF] [-h number] [-r address] [-s subject] user...
mailx [-dinNveH] -f [file]
Mail [-dinNveH] -f [file]
mailx [-dinNveH] [-u user]
Mail [-dinNveH] [-u user]
The mailx and Mail commands allow you to read, write, send, receive,
store, and discard mail messages.
[Tru64 UNIX] See the section Internationalization under the DESCRIP‐
TION section for more information about the internationalization fea‐
tures of the mailx command.
Interfaces documented on this reference page conform to industry stan‐
dards as follows:
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
Causes the mailx command to display debugging information. Messages are
not sent while in debug mode. Tests for the presence of mail. The
mailx command prints nothing and exits with a successful return code if
there is mail to read. Reads in the contents of your mbox or the spec‐
ified file for processing. When you quit, mailx writes undeleted mes‐
sages back to this file. Records the message in a file named after the
first recipient. Overrides the record option, if set. Specifies the
number of network “hops” made so far. This is provided for network
software to avoid infinite loops. Prints header summary only. Ignores
tty Interrupt signals. Useful when using mailx on noisy phone lines.
Inhibits the reading of the /usr/share/lib/Mail.rc file. Suppresses
the initial printing of headers. Changes sender's address to address.
The original sender must be a trusted user. See sendmail(8) for more
information on trusted users. Specifies a subject for a message to be
created. Activates mailx for a specified users mailbox; short way of
doing mailx-f /var/spool/mail/user. You must have access permission
to the specified user's mailbox. Puts mailx into verbose mode.
Details of delivery are displayed on the user's terminal.
The mailx and Mail commands allow you to do the following: Compose a
message and send it. Receive a message and look at it. Store received
messages in your mailbox or in folders. Discard messages.
The mailx command uses two types of mailboxes: the system mailbox and
the personal mailbox. The system mailbox is a file assigned to a par‐
ticular user. The file is created when mail arrives for a user ID, and
it is deleted when all the messages are removed from the file. It is
not deleted if you have specified the keep option in your file, or if
the /var/spool/mail directory has no write permissions for other. A
separate system mailbox can exist for each user ID on the system. The
mailx command keeps all system mailboxes in the directory
/var/spool/mail. Each system mailbox is named by the user ID associ‐
ated with it. For example, if your user ID is jeanne, then your system
mailbox is /var/spool/mail/jeanne.
The personal mailbox is a file assigned to a particular user. The
mailx command creates a file with the name $HOME/mbox when you receive
mail from the system mailbox. For example, if your home directory is
/u/lance, the mailx command creates the file /u/lance/mbox as your per‐
sonal mailbox. The system deletes this file when all messages are
removed from the personal mailbox. When you use the mailx command to
view mail in your system mailbox, the mailx command automatically puts
all messages that you have read but did not delete into your personal
mailbox. The messages remain in your personal mailbox until you move
them to a folder or delete them.
Folders provide a way to save messages in an organized fashion. You
can create as many folders as you need. Name each folder according to
the subject matter of the messages that it contains. Using the mailx
command, you can put a message into a folder from your system mailbox,
from your personal mailbox, from the dead.letter file, or from another
To send a message to one or more persons, enter mailx on the command
line with arguments that are the network addresses of the people you
want to receive the message. When mailx starts, you can type the mes‐
sage using an editor such as ed. When you are finished with the mes‐
sage, press <Return> at the end of a line, and use an End-of-File key
sequence at the beginning of the next line to exit the editor and send
When mail arrives for you from another user, the mail system puts the
mail in your system mailbox (/var/spool/mail/user). The command shell
will notify you that mail has arrived before displaying its next prompt
(that is, notification is synchronous), provided that the MAIL environ‐
ment variable is set and the interval specified by MAILCHECK (mail for
csh) has elapsed since the shell last checked for mail. If you are
logged in, the shell sends a message to your terminal to tell you that
new mail has arrived. If you are not logged in, a message is sent to
your terminal the next time you log in. The notification message is
the value of the MAILMSG environment variable. The default message is
as follows: [YOU HAVE NEW MAIL]
To look at the contents of your mailbox, enter the mailx command with‐
out options on the command line. The program displays a listing of the
messages in your mailbox and allows you to look at them, reply to them,
save them, dispose of them, and so on.
[Tru64 UNIX] Tru64 UNIX provides locking for the mailbox files. The
style of locking used depends on how it is set in the rc.config.common
file. For more information, see mail_manual_setup(7).
Reading Incoming Mail
To receive and read incoming mail, enter mailx with no arguments: mailx
The mailx command then checks your system mailbox
(/var/spool/mail/user) and displays a one-line entry for each message
in the system mailbox similar to the following: "/var/spool/mail/geo":
2 messages 2 new >N 1 amy Thu Sep 17 14:36 13/359 "Dept Meeting"
N 2 amy Thu Sep 17 16:28 13/416 "Dept Meeting Delayed" ?
The > (right angle bracket) indicates the current message, or the mes‐
sage that subcommands act on if you do not specify a message number or
list of message numbers. The first field for each message contains a
one-letter indicator of the status of the message. Possible indicators
are as follows: The message is stored in your personal mailbox. The
message is new. The message is held (preserved) in your system mail‐
box. You have read the message. The message is unread. The message
was listed in the mailbox before, but you have not looked at the con‐
tents of the message. You have saved or written the message to a file
or folder. The message was read, but was not deleted or saved.
The other fields in the listing (in order) represent: The number that
mailbox subcommands use to refer to the message. User address of the
sender. Date the message was received, including day of the week,
month, day, and time. Size of the message in number of lines and char‐
acters, including header information. The contents of the subject
field of the message, if the message has one.
From the mailbox prompt (?), you can enter subcommands to look at,
reply to, save, discard, or otherwise manage the contents of the mail‐
box. To display a summary of some of the subcommands that you can use
to handle mail in your mailbox, enter a ? (question mark) at the mail‐
box prompt. Note that the behavior of the <Return> key has changed for
XCU4.2 compliance. Using this key with no following argument now
causes the current message to be displayed, and not the next message.
Many mailbox subcommands allow you to specify groups of messages upon
which to perform the subcommand. Subcommands that allow groups of mes‐
sages use the argument message_list in the command format. For exam‐
ple, the format of the from (or f) subcommand (display information
about messages) appears as:
? from [message_list]
In this format, message_list can be one of the following: One or more
message numbers separated by spaces. For example:
? f 1 2 4 7 A range of message numbers indicated by the first
and last numbers in the range separated by a dash. For example,
the following subcommand:
? f 2-5
is the same as:
? f 2 3 4 5 An example of one or more addresses separated by
spaces to apply the subcommand to messages received from those
? f amy geo@zeus
The characters entered for an address need not match the address
exactly. They must only be contained in the address field of
the messages in either uppercase or lowercase letters. There‐
fore, the request for address amy matches all of the following
addresses (and many others): amy AmY amy@zeus hamy A string,
preceded by a / (slash), to match against the Subject: field of
the messages follows:
? f /meet
This applies the subcommand to all messages whose Subject: field
contains the letters meet in uppercase or lowercase. The charac‐
ters entered for a match pattern do not have to match the Sub‐
ject: field exactly. They must only be contained in the Sub‐
ject: field of the messages in either uppercase or lowercase.
Therefore, the request for subject meet matches all of the fol‐
lowing subjects (and many others): Meeting on Thursday Come to
meeting tomorrow MEET ME IN ST. LOUIS
The special character (dot) addresses the current message, * (asterisk)
addresses all messages, ^ (circumflex) addresses the first undeleted
message, and $ (dollar sign) addresses the last message. The character
sequence :c addresses all messages of type c, where c is one of the
following: Deleted messages New messages Old messages Read messages
All commands that take a message list will default to the current mes‐
sage number if no list is specified.
When the mailx command is processing a mailbox, the mailbox prompt (?)
is displayed to indicate that it is waiting for input. When this
prompt is displayed, you can enter any of the following mailbox subcom‐
mands. The subcommand abbreviation in parentheses can be used instead
of the full subcommand name. Echoes the number of the current message.
Allows you to write comments in mail script files. Goes to the previ‐
ous message and displays it. If given a number argument of n, goes to
the nth previous message and displays it. Displays a brief summary of
mailbox subcommands. Executes shell_command. Displays all currently
defined aliases. With the argument of a previously defined alias, dis‐
plays the expansion of the alias. With at least two arguments, alias
and address_list (a space-separated list of addresses), creates a new
alias or changes an old alias. Identical to the group subcommand.
Informs mailx that the addresses listed in alternate_list all refer to
you. The alternates subcommand is useful if you have accounts on sev‐
eral machines. Then, when you reply to messages, mailx does not send a
copy of the message to any of the addresses given in alternate_list. If
you enter the alternate subcommand with no argument, mailx displays the
current set of alternate names. Changes your working directory to
directory. If no directory is given, it changes to your login direc‐
tory. Appends each message in message_list in turn to the end of file.
Displays the filename in quotes, followed by the line count and charac‐
ter count, on your terminal. Does not mark the appended messages for
deletion when you quit. Saves the specified messages in a file whose
name is derived from the author of the message to be saved, without
marking the messages as saved. Otherwise equivalent to the Save sub‐
command. Marks the messages in message_list to be deleted when you
quit mailx. Deleted messages are not saved in mbox, nor are they
available for most other subcommands. However, you can restore messages
that you have deleted while in the same mailbox session (see the
undelete subcommand). If you delete a message and either change to
another mailbox or quit the mailbox with the quit subcommand, the
deleted message cannot be recalled. Identical to the ignore subcom‐
mand. Deletes the current message and displays the next message. If
there is no next message, mailx displays the message, at EOF. Identi‐
cal to the dp subcommand. Displays the character string string on the
command line. Invokes the alternate editor that you can define with
the set EDITOR= statement and loads message_list into the editor. When
you exit the editor, any changes made during the editing session are
saved in the messages in message_list. The default editor is
/usr/bin/ex. Exits to the shell without changing the mailbox being
processed. The mailbox returns to the condition that it was in when
mailx was started. Messages marked to be deleted are not deleted.
Identical to the xit subcommand. Identical to the folder subcommand.
Switches to a new mail file or folder. With no arguments, displays the
name of the mailbox that you are currently reading. If an argument is
included, it stores the current mailbox with changes (such as messages
deleted) and reads in the new mailbox specified by the name argument.
Identical to the file subcommand.
Some special conventions are recognized for the name: Refers to
the previous file. Refers to the system mailbox
(/var/spool/mail/user). Refers to your personal mailbox
($HOME/mbox). Refers to a file in your folder directory (deter‐
mined by the value of the folder option; see Enabling and Dis‐
abling Options). Lists the names of the folders in your folder
directory (see the folder option in Enabling and Disabling
Options). Responds to a message, recording the response in a
file whose name is derived from the author of the message.
Overrides the record option, if set. (See also the Followup,
Save, and Copy subcommands and the outfolder option.) Responds
to the first message in message_list, sending the message to the
author of each message in message_list. The subject line is
taken from the first message and the response is recorded in a
file whose name is derived from the author of the first message.
(See also the followup, Save, and Copy commands and the out‐
folder option.) Displays the headers of messages in mes‐
sage_list. Identical to the alias subcommand. Lists the head‐
ers in the current group of messages (each group of messages
contains 20 messages by default; change this with the set
screen= statement). If the mailbox contains more messages than
can be displayed on the screen at one time, information about
only the first group of messages is displayed. To see informa‐
tion about the rest of the messages, use the h subcommand with a
message number that is in the next range of messages, or use the
z subcommand to change the current message group. Displays a
brief summary of mailbox subcommands. Identical to the ?
(question mark) subcommand. Marks each message in message_list
to be saved in your system mailbox (/var/spool/mail/user)
instead of in $HOME/mbox. Does not override the delete subcom‐
mand. Identical to the preserve subcommand. Construction for
conditional execution of mailx subcommands. Subcommands follow‐
ing if are executed if condition is TRUE. Subcommands following
else are executed if condition is not TRUE. The else is not
required. The endif subcommand ends the construction and is
required. The condition can be receive (receiving mail) or send
(sending mail). Adds the header fields in field_list to the
list of fields to be ignored. Ignored fields are not displayed
when you look at a message with the type or print subcommands.
Use this subcommand to suppress machine-generated header fields.
Use the Type and Print subcommands to print a message in its
entirety, including ignored fields. If ignore is executed with
no arguments, it lists the current set of ignored fields. Iden‐
tical to the discard subcommand. Displays a list of valid mailx
subcommands. Lists other names for the local host. Activates
the mail editor to allow you to create and send a message to
people specified in address_list. The newly created message is
independent from any received messages. Indicates that the mes‐
sages in message_list be sent to your personal mailbox when you
quit. This operation is the default action for messages that
you have looked at if you are looking at your system mailbox and
the hold option is not set. Displays the messages inmes‐
sage_list using the defined pager program to control the display
to the screen. Identical to the page subcommand. Like more, but
also displays ignored header fields. (See more and ignore.)
Marks each message in message_list as not having been read.
Identical to the New, unread, and Unread subcommands. Marks
each message in message_list as not having been read. Identical
to the new, unread, and Unread subcommands. Makes the next mes‐
sage in the mailbox the current message, and displays that mes‐
sage. With an argument list, it displays the next matching mes‐
sage. Displays the messages in message_list using the defined
pager program to control the display to the screen. Identical to
the more subcommand. Like the page subcommand, but also dis‐
plays ignored header fields. Identical to the More subcommand.
Pipes the message through shell_command. The message is treated
as if it were read. If no arguments are given, the current mes‐
sage is piped through the command specified by the value of the
cmd option. If the page option is set, a formfeed character is
inserted after each message. Identical to the hold subcommand.
Displays the messages in message_list. Identical to the type
subcommand, or simply pressing the <Return> key with no argu‐
ment. Like print, but also displays ignored header fields.
(See print and ignore.) Identical to the Type subcommand. Ends
the session and returns to the shell. All messages that were
not deleted or saved are stored in your personal mailbox
($HOME/mbox). All messages marked with hold or preserve and
those messages that you did not look at are saved in the system
mailbox (/var/spool/mail/user). If the quit subcommand is given
while editing a mailbox file with the -f option, then the edit
file is saved with the changes. If the edit file cannot be
saved, mailx does not exit. Use the exit subcommand to exit
without saving the changes. Allows you to reply to the sender
of message and to all others who received copies of message.
Identical to the respond subcommand. Allows you to reply only
to the sender of message. Identical to the Respond subcommand.
Allows you to reply to the sender of message and to all others
who received copies of message. Identical to the reply subcom‐
mand. Allows you to reply only to the sender of message. Iden‐
tical to the Reply subcommand. Adds the header fields in
field_list to the list of fields to be retained. Retained
fields are displayed when you look at a message with the type or
print subcommands. Use this subcommand to define which header
fields you want displayed. Use the Type and Print subcommands
to print a message in its entirety, including fields that are
not retained. If retain is executed with no arguments, it lists
the current set of retained fields. Saves message_list, includ‐
ing header information, to file (or to a folder). If file
already exists, message_list is appended to file. Displays the
filename and the size of the file when the operation is com‐
plete. If you save a message to a file, that message is not
returned to the system mailbox nor saved in your personal mail‐
box when you quit the mailx command. If a filename is not speci‐
fied, the mailx command saves the messages in your personal
mailbox. Saves the specified messages in a file whose name is
derived from the author of the first message. The name of the
file is taken to be the author's name with all network address‐
ing stripped off. (See also the Copy, followup, and Followup
subcommands, and the outfolder option.) Displays the options
that are currently enabled. If arguments are specified, sets
options in option_list (a list of binary options, those that are
either set or not set); or sets an option that must be assigned
a value. (See Enabling and Disabling Options for a description
of valid options.) Invokes an interactive version of the shell.
Displays the sizes in lines and characters of the messages in
message_list. Reads and executes the mailx commands from file.
Displays the top few lines of the messages specified by mes‐
sage_list. The number of lines displayed is determined by the
valued option toplines and defaults to 5. Marks the messages in
message_list to be moved from your system mailbox to your per‐
sonal mailbox when you quit the mailx command, even though you
have not read the listed messages. The messages appear in your
personal mailbox as unread messages. When you use touch, the
last message in message_list becomes the current message. Dis‐
plays the messages in message_list. Identical to the print sub‐
command. Like type, but also displays ignored header fields.
(See type and ignore.) Identical to the Print subcommand.
Deletes the specified alias names. If a specified alias does
not exist, the results are unspecified. Removes the messages in
message_list from the list of messages to be deleted when you
quit mailx. Without a message_list, undelete recalls the last
deleted message. Marks each message in message_list as not hav‐
ing been read. Identical to the new, New, and Unread subcom‐
mands. Marks each message in message_list as not having been
read. Identical to the new, New, and unread subcommands. Dis‐
cards the values of the options specified in option_list. This
action is the inverse of the set subcommand. Displays the ver‐
sion banner for the mailx command. Invokes the visual editor
and loads message_list into the editor. (This editor can be
defined with the set VISUAL= statement.) When you exit the edi‐
tor, any changes made during the editing session are saved back
to the messages in message_list. Appends the messages specified
in message_list to file. Displays the filename and the size of
the file when the operation is complete. Does not include mes‐
sage headers in the file. Identical to the exit subcommand.
Changes the current message group (group of 20 messages) and
displays the headers of the messages in that group. If a + or no
argument is given, then headers in the next group are shown. If
a - argument is given, the headers in the previous group are
You can use the mailx command in one of two ways to send information.
You can use the mailx command's built-in editor to both compose and
send a short message. You can also use the mailx command to send any
text file to another user. The file can be a letter you have written
using your favorite editor, a source file for a program you have writ‐
ten, or any other file in text format.
The mailx command provides a line-oriented editor for composing mes‐
sages. This editor allows you to enter each line of the message and
then press <Return> to get a new line to enter more text. You cannot
change the text after you press <Return>. However, before you press
<Return>, you can change text on the current line by using <Backspace>
and <Delete> to erase the text and then enter the replacement text.
Although you cannot change text on a line once you have pressed
<Return>, you can change the contents of your message before sending it
by using the visual or edit subcommand to edit the message.
By default, mailx treats lines beginning with the ~ (tilde) character
as special while you are composing a message. For instance, entering
~m on a line by itself places a copy of the current message into the
response, shifting it to the right by one tab stop.
Other escapes set up subject fields, add and delete recipients of the
message, and allow you to escape to an editor to revise the message, or
to a shell to run other commands. You can change the Escape character
to something other than a tilde with the set escape= statement. To
view a summary of many useful commands, enter ~? on a line by itself
while in the mail editor.
The following list provides a summary of the mail editor commands. Use
these commands only while in the mail editor. The editor recognizes
commands only if you enter them at the beginning of a new line.
Escapes to command mode. Displays a summary of the mailx subcommands.
Executes the shell command and returns to the message. Simulates End-
of-File (terminates message input). Performs the command-level
request. Valid only when sending a message while reading mail.
Inserts the autograph string from the sign= option into the message.
Inserts the autograph string from the Sign= option into the message.
Adds names in address_list to the list of people to receive blind
copies of the message. Can only be used to add to (not to change or
delete) the contents of the Bcc: list. Adds names in address_list to
the list of people to receive copies of the message. Can only be used
to add to (not to change or delete) the contents of the Cc: list.
Dumps core. Appends the file dead.letter from your home directory to
the current end of the message. Invokes the alternate editor using the
text of the current message as input. (This editor can be defined with
the set EDITOR= statement.) When you exit that editor, you return to
the mail editor, where you can continue appending text to the message,
or you can send the message by quitting the mailx command. Includes
one or more additional messages in the current message to forward to
another user. This subcommand reads each message in message_list and
appends it to the end of the current message, but it does not indent
the appended messages. This subcommand is also used to append messages
for reference when the margins are too wide to imbed with the ~m sub‐
command. The ~f subcommand works only if you entered the mail editor
from the mailbox prompt using the mail subcommand, the reply subcom‐
mand, or the Reply subcommand. Performs the same operation as the ~f
command escape, except that all headers are included in the message,
regardless of previous discard, ignore, and retain commands. Allows
you to add or to change information in all of the header fields. The
system displays each of the four header fields, one at a time. You can
view the contents of each field and delete or add information to that
field. Press <Return> to save any changes to that field and to display
the next field and its contents. Inserts the value of the named option
into the text of the message. For example, ~A is equivalent to ~i
Sign. Reads message_list into the current messagefor reference pur‐
poses. This subcommand reads each message in message_list and appends
it to the current message. The included message is indented one tab
character from the normal left margin of the message. This subcommand
works only if you entered the mail editor from the mailbox prompt using
the mail subcommand, the reply subcommand, or the Reply subcommand. If
no messages are specified, it reads the current message. Performs the
same operation as the ~m command escape, except that all headers are
included in the message, regardless of previous discard, ignore, and
retain commands. Displays the message as it currently exists, prefaced
by the message header fields. Quits the editor, aborting the message
being created without sending it. Saves the message in the dead.letter
file in your home directory, unless the nosave option is set. The pre‐
vious contents of the dead.letter file are overwritten by the partially
You can also quit the editor by using the Interrupt key
sequence. Reads the named file into the message. If the argu‐
ment begins with !, the rest of the string is taken as an arbi‐
trary system command and is executed, with the standard output
inserted into the message. Changes the Subject: field to the
phrase specified in string. Adds the addresses in address_list
to the To: field of the message. Can only be used to add to (not
to change or delete) the contents of the To: list. Invokes the
visual editor using the text of the current message as the input
file. (This editor can be defined using the set VISUAL= state‐
ment.) When you exit that editor, you return to the mail editor,
where you can continue appending text to the message, or you can
send the message by quitting the mailx command. Writes the mes‐
sage to the named file. Exits as with ~q, except the message is
not saved in dead.letter. Pipes the message through command as
a filter. If command gives no output or terminates abnormally,
it retains the original text of the message. Otherwise, the
output of command replaces the current message. The fmt command
is often used as command to format the message. Allows you to
use the ~ (tilde) character in a message without it being inter‐
preted as a command prefix. The sequence ~~ (two tildes)
results in only one ~ being sent in the message.
Customizing the Mail Program
The system manager uses the /usr/share/lib/Mail.rc file to define the
initial configuration for the mailx command. The subcommands in this
file override the default characteristics of the mailx command for all
users on the system. Although the initial configuration can meet the
needs of most users, you can alter it by creating the $HOME/.mailrc
file. Subcommands in this file override similar subcommands in
/usr/share/lib/Mail.rc when you run the mailx command. The following
subcommands are not legal in the start-up file: !, Copy, edit, fol‐
lowup, Followup, hold, mail, preserve, reply, Reply, shell, and visual.
There are four mail subcommands that are most commonly used to alter
the characteristics of the mailx session: set, unset, alias, and
ignore. The set and unset subcommands enable and disable mail options,
the alias subcommand shortens how you address mail, and the ignore sub‐
command suppresses message header fields.
Enabling and Disabling Options
The following are environment variables taken from the execution envi‐
ronment and are not alterable within mailx: The name of the locale for
performing character conversions on outgoing messages. The pathname of
the user's home directory. The name of the locale for displaying mail
messages. The name of the start-up file. The default is
Use the set subcommand to enable options and the unset subcommand to
disable options. Options can be either binary or valued. Binary
options are either set or unset, while valued options can be set to a
specific value. You can set options by placing set subcommand lines in
your $HOME/.mailrc file.
The syntax for enabling options using the set subcommand is as follows:
set [option_list | option=value]
The syntax for disabling options using the unset subcommand is as fol‐
lows: unset [option_list]
The following is a list of binary options (those that can be set or
unset): Off by default; all network names with the same login name are
treated as being the same. Causes messages saved in mbox to be
appended (added to the end) rather than prepended (added to the begin‐
ning). Causes mailx to prompt you for the subject of each message you
send. If you respond with a newline (carriage return), no subject
field is set. This option is enabled by default. Causes mailx to
prompt you for the address of people to receive blind carbon copies of
the message. Responding with a newline indicates satisfaction with the
current list. The default is noaskbcc. Causes you to be prompted for
the addresses of people to receive copies of the message. Responding
with a newline indicates your satisfaction with the current list.
Prompts for subject if it is not specified on the command line with the
-s option. Identical to ask. Causes the delete subcommand to behave
like dp. Thus, after deleting a message, the next one is typed automat‐
ically. Enables the special-case treatment of ! (exclamation points)
in escape command lines as in vi. The default is nobang. Causes mailx
to display debugging information. The mailx command does not send mail
while in debug mode. Same as specifying -d on the command line. Causes
mailx to interpret a period alone on a line as the terminator of a mes‐
sage you are sending. Reverses the meaning of the R and r commands.
The default is noflipr. Enables printing of the header summary when
entering mailx. This option is enabled by default. Holds messages in
the system mailbox by default. Causes Interrupt signals from your ter‐
minal to be ignored and echoed as @'s. Makes mailx refuse to accept
End-of-File key sequence as the end of a message or as the quit subcom‐
mand. Related to the dot subcommand. Truncates the mailbox to zero
length when it is empty, instead of removing it. This option is dis‐
abled by default. Keeps messages that have been saved in other files
in the mailbox, instead of deleting them. The default is nokeepsave.
Causes the sender to be included in the alias expansion, and thus
receives copies of messages. Usually, when an alias containing the
sender is expanded, the sender is removed from the expansion. Used
when replying to a message sent to several users and prevents the
addresses of the recipients from being made relative to the address of
the original author. You can use this variable only on a network where
all systems can connect to one another directly. Prevents mailx from
copying the partial letter to the file dead.letter in your home direc‐
tory when a message is terminated with two Interrupt key sequences.
Causes the files used to record outgoing messages to be located in the
directory specified by the folder option unless the pathname is abso‐
lute. The default is nooutfolder. (See the folder option and the
Save, Copy, followup, and Followup subcommands.) Inserts a formfeed
after each message sent through the pipe when used with the pipe com‐
mand. The default is nopage. Suppresses the printing of the program
banner when mailx starts. (The banner is the line that shows the name
of the mail program.) Reverses the sense of the reply and Reply mail‐
box subcommands. Enables saving of messages in dead.letter on inter‐
rupt or delivery error. (See DEAD= for a description of this file.
This option is enabled by default.) Waits for the background mailer to
finish before returning. The default is nosendwait. Prints the recip‐
ient's name instead of the author's name when displaying the header
summary and the message is from the user. Runs mailx in verbose mode;
the actual delivery of messages is displayed on the user's terminal.
Same as using the -v option on the command line.
The following is a list of valued options (those that can be assigned a
value). The syntax for assigning values is set option=value. Sets the
default command for the pipe subcommand. There is no default value.
Off by default; used to convert uucp addresses for sendmail. Causes
the paging program to automatically be invoked for messages that exceed
number lines. Specifies the name of the file in which to save partial
letters in case of untimely interrupt or delivery errors. The default
is $HOME/dead.letter. Defines the text editor invoked by the ~e and
edit subcommands. The absolute pathname must be given. The default
editor is /usr/bin/ex. Defines a character to use in the place of ~
(tilde) to denote escapes. Sets the locale for performing character
conversion on outgoing messages. The default is None. Defines the
name of the directory to use for storing folders of messages. If this
name begins with a / (slash), mailx considers it to be an absolute
pathname; otherwise, the folder directory is found relative to your
home directory. Specifies a string that is prefixed to each line
inserted into the message by the ~m command escape. The default string
is one <Tab> character. Sets the locale for displaying mail messages.
The default is C. Specifies the command (and arguments) to use when
listing the contents of the folder directory. The default is ls.
Specifies the name of the system mailbox, by default
/var/spool/mail/username. Specifies the name of the file in which to
save messages that have been read. The exit subcommand overrides this
function, as does saving the message explicitly in another file. The
default is $HOME/mbox. Specifies the pathname of the paging program to
use for the more subcommand or when the crt option is set. If you do
not specify a value for PAGER, the system uses /usr/bin/pg. Sets the
command mode prompt to string. The default is ?. Specifies the path‐
name of the file (relative to $HOME) used to record all outgoing mail.
A copy of all the messages you send out is saved in this file. Review
this file periodically and delete all unnecessary messages.
The mailx subcommands do not create directories, so any directo‐
ries included in the pathname must already exist before using
this subcommand. Do not include the home directory as part of
the pathname. If record is not defined, then copies of outgoing
mail are not saved. Controls how many lines of the message list
are displayed at a time. You can set this option to show a cer‐
tain number of lines on the screen. Each message in your mail‐
box has a one-line header in the message list. If you have more
than 24 messages, the first headers from the message list scroll
past the top of your screen whenever you display the list.
Specifies an alternative command for delivering mail. Specifies
the pathname of the shell to use in the ! and ~! subcommands.
If this option is not defined, your default shell is used.
Specifies the variable inserted into the text of a message when
the ~a (autograph) subcommand is given. (See also the ~i tilde
escape.) There is no default value. Specifies the variable
inserted into the text of a message when the ~A subcommand is
given. (See also the ~i tilde escape.) There is no default
value. Specifies the number of lines of a message to be dis‐
played with the top subcommand; normally, the first five lines
are displayed. Specifies the pathname of the text editor to use
in the visual and ~v subcommands. The default pathname is
Creating Aliases and Distribution Lists
If you send mail on a large network or often send the same message to a
large number of people, entering long addresses for each receiver can
become tedious. To simplify this process, you can create an alias or a
distribution list in your $HOME/.mailrc file.
An alias is a name you define that can be used in place of a user
address when you address mail. A distribution list is a name that you
define that can be used in place of a group of user addresses when you
Aliases and distribution lists are used the same way and defined in
similar ways; the only difference is the number of addresses defined
for an alias (one address) and a distribution list (more than one
Changing the Information at the Top of a Message
You can use the ignore subcommand to suppress message header fields
that are normally displayed when you read a message using the type or
print subcommands. The four message header fields are To, Subject, Cc,
The syntax of the ignore subcommand is as follows: ignore [field_list]
Note that fields are specified without a trailing : (colon). You can
include the fields you want to ignore in your $HOME/.mailrc file.
[Tru64 UNIX] The mailx command supports codeset conversion of mail
messages between the mail interchange code (specified by the EXCODE
environment variable) used to transmit messages to other hosts and the
application code (specified by the LANG environment variable) used by
the user. For example, if the mail interchange code is ISO-2022-JP and
the application code is eucJP, the mailx program converts incoming mes‐
sages from ISO-2022-JP to the Japanese EUC character set when display‐
ing them and converts outgoing mail message from the Japanese EUC char‐
acter set to ISO-2022-JP.
To prevent data loss, incoming mail messages are stored in the mail
folders as received, without conversion. The conversion takes place
when you display or extract mail messages.
To encode the mail interchange code information, new header lines are
added to the outgoing mail messages. For example, if the mail inter‐
change code is ISO-2022-JP, the following additional header lines are
Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-2022-JP
The charset field of the Content-Type header line provides the mail
interchange code information. For non-ISO codesets, the prefix X- is
added to the character set name for identification purposes. For exam‐
Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-eucJP
For incoming mail messages, the mail interchange to be used is deter‐
mined by the charset field of the additional header lines, if present.
For outgoing mail messages, the following rules determine the mail
interchange code to be used: The EXCODE environment variable. The
excode valued option defined in $HOME/.mailrc or /usr/share/lib/Mail.rc
The application code is determined from the codeset part of the follow‐
ing locale information: The LANG environment variable. The lang valued
option defined in $HOME/.mailrc or /usr/share/lib/Mail.rc Defaults to
Note that you must specify a mail interchange code to do character con‐
version. There are no defaults.
All messages associated with conversion are informational only. The
mail messages in question are still delivered or received.
The excode and lang options are recognized only within $HOME/.mailrc or
/usr/share/lib/Mail.rc. Setting these options within mailx has no
The mailx command uses only mailbox files. It does not use POP or IMAP
To save a message to a folder, enter the following at the mailbox
prompt (?): save 1 +procedures
The following message is displayed: /u/jay/doc/procedures
In this example, message 1 was added to the end of the folder
procedures. User jay has the following set folder statement in
his $HOME/.mailrc file so that the folder directory where that
folder is kept is already selected:
set folder=/u/jay/doc To look at the contents of a specific mail
folder, enter the following at the command-line prompt: mailx-f
In this example, a listing of the messages in the dept folder is
displayed. To prevent the Date, From, and To headers from being
displayed when a message is read with the type or the print sub‐
command, enter the following statement in your $HOME/.mailrc
file: ignore date from to
When a message is displayed using the type or print subcommand,
the date, from, and to headers are not displayed. However, if
you want to display these headers without deleting the ignore
statement from your $HOME/.mailrc file, use the Type, Print, or
top subcommands to display the message. To keep a record of
messages you send to others, enter the following statement in
your $HOME/.mailrc file: set record=letters/mailout To create a
distribution list for your department, enter the following
statement in your $HOME/.mailrc file: alias dept dee@merlin
anne@anchor jerry@zeus bill carl
To send a message to your department after you have added this
line to your $HOME/.mailrc file, enter the following at the com‐
mand line prompt: mailx dept
The message you now create and send will go to dee on system
merlin, anne on system anchor, jerry on system zeus, and to bill
and carl on the local system.
User mailbox files. Holds saved mail. File containing mailx subcom‐
mands to customize mailx for a specific user. File containing mailx
subcommands to change mailx for all users on the system.
Commands: mail(1), fmt(1), pg(1), sendmail(8)