mailx(1) General Commands Manual mailx(1)
NAME
mailx - interactive mail message processing system
SYNOPSIS
Send mode
subject] address] number] address ...
Receive mode
user]
[filename]
Obsolescent
filename]
DESCRIPTION
provides a comfortable, flexible environment for sending and receiving messages electronically. When reading mail, provides commands to
facilitate saving, deleting, and responding to messages. When sending mail, allows editing, reviewing and other modification of the mes-
sage as it is created.
Incoming mail for each user is stored in a standard file called the system mailbox for that user. When using to read messages, the system
mailbox is used unless an alternate mailbox file is specified by using the option with or without a specific filename. As incoming mes-
sages are read from the system mailbox, they are marked to be moved to a secondary file for storage (unless specific action is taken) so
that the messages need not be seen again. This secondary file is called the mbox and is usually located in the user's directory (see in
the subsection for a description of this file and other environment variables used by Messages remain in this file until specifically
removed.
Command-line options start with a hyphen and any other arguments are assumed to be destinations (recipients).
Arguments containing multiple words must be enclosed in quotes.
If no recipients are specified, attempts to read messages from the system mailbox.
Recipient addresses specified on the command line must total less than 1024 characters in length. You may declare an or (see the section)
to specify a recipient address or list of addresses of up to 8191 characters, and use that alias or group name (though each address in the
list must still be less than 1024 characters). If you wish to specify a list of recipient addresses of greater length than this, have your
system administrator declare an alias or group in the system alias file and use that alias name instead.
Options
recognizes the following command-line options:
Test for presence of mail.
prints nothing and exits with a successful return code if there is mail to read. Sometimes used in login scripts
such as to check for mail during login.
Read messages from
filename instead of from the user's system mailbox. If filename is not specified, the secondary mbox is used.
Note: When using the
option in do not specify a system mailbox (for example, as the filename. According to the standards, the option can-
not be used to read the system mailbox messages. The behavior of in this circumstance is undefined.
The behavior of
is also undefined in these circumstances:
o When the and options are used together in the command line.
o When the or option is used multiple times in the command line.
Record the message in a file named after the first recipient.
Overrides the environment variable, if set.
The number of network "hops" made so far.
This is provided for network software to prevent infinite delivery loops.
Print header summary only.
Print complete header information only.
Ignore interrupts.
Also see the description of the environment below.
Do not initialize from the system default
file.
Do not add MIME header lines
Mime Version, Content Type & Content Encoding to the header information while sending mails.
Do not print initial header summary.
Pass address to network delivery software. All tilde commands are disabled.
Set the Subject header field to
subject.
Read user's mailbox. Can be used only if read access to user's mailbox is not read protected.
Convert UUCP-style addresses to Internet standards. Overrides the environment variable.
Turn on debugging output.
Neither particularly interesting nor recommended.
When reading mail, operates in command mode. A header summary of the first several messages is displayed, followed by a prompt indicating
that can accept regular commands (see the section). When sending mail, operates in input mode. If no subject is specified on the command
line, a prompt for the subject is printed. As the message is typed, reads the message and stores it in a temporary file. Commands can be
entered by beginning a line with the tilde escape character followed by a single command letter and optional arguments. See the section
for a summary of these commands.
The behavior of at any given time is governed by a set of environment variables; flags and valued parameters that are set and cleared by
using the and commands. See the subsection for a summary of these parameters.
Recipients listed on the command line can be of three types: login names, shell commands, or alias groups. Login names can be any network
address, including mixed network addressing. If the recipient name begins with a pipe symbol the rest of the name is assumed to be a shell
command to pipe the message through. This provides an automatic interface with any program that reads the standard input, such as (see
lp(1)) for recording outgoing mail on paper. Alias groups are set by the command (see the section) and are lists of recipients of any
type.
Note: To send a message to an name that is prefixed with a plus (+) symbol, the name with the plus (+) symbol must be placed within double
quotes ("), as specified below:
subject]
If the double quotes are not used, considers the name as a user-specified file name beginning with a plus symbol, similar to the option
under
Regular commands are of the form
[command] [msglist ] [ arguments ]
If no command is specified in command mode, is assumed. In input mode, commands are recognized by the escape character (tilde unless rede-
fined by the environment variable), and lines not treated as commands are treated as input for the message.
Each message is assigned a sequential number, and there is always the notion of a current message, marked by a in the header summary. Many
commands take an optional list of messages (msglist) to operate on, which defaults to the current message. A msglist is a list of message
specifications separated by spaces. The message list can include:
n Message number n.
The current message.
The first undeleted message.
The last message.
All messages.
An inclusive range of message numbers,
n through m, where n is less than m.
user All messages from user.
All messages with
string in the subject line (uppercase-lowercase differences are ignored).
All messages of type
c, where c is one of:
deleted messages
new messages
old messages
read messages
unread messages
Note that the context of the command determines whether this type of message specification makes sense.
Other arguments are usually arbitrary strings whose usage depends on the command involved.
File names, where expected, are expanded using normal shell conventions (see sh(1)). Special characters are recognized by certain com-
mands, and are documented with the commands below.
At start-up time, reads commands from a system-wide file to initialize certain parameters, then from a private start-up file for personal-
ized variables. Most regular commands are legal inside start-up files, the most common use being to set up initial display options and
alias lists. The following commands are not legal in the start-up file: and Any errors in the start-up file cause the remaining lines in
the file to be ignored.
COMMANDS
The following is a complete list of commands:
Escape to the shell.
See the description of the environment variable below.
Null command (comment).
Useful in files.
Print the current message number.
Print a summary of commands.
newline Advance to next message and If this is the first command entered, the first unread message is printed. (To read the
current message, use
Declare an alias for the given names.
The names are substituted when alias is used as a recipient. Useful in the file.
Declares a list of alternate names for your login.
When responding to a message, these names are removed from the list of recipients for the response. With no arguments,
prints the current list of alternate names. See also in the subsection.
Change directory. If directory is not specified, is used.
Copy messages to the file without marking the messages as saved.
Otherwise equivalent to the command.
Save 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 com-
mand.
Delete messages from the
mailbox. If is set, the next message after the last one deleted is printed (see the subsection). See also
Suppresses printing of the specified header fields
when displaying messages on the screen. Examples of header fields to ignore are "status" and "cc." The fields are
included when the message is saved. The and commands override this command.
Delete the specified messages from the mailbox
and print the next message after the last one deleted. Roughly equivalent to a command followed by a command.
Echo the given string or strings (similar to
- see echo(1)).
Edit the given messages.
The messages are placed in a temporary file and the variable is used to get the name of the editor (see the subsec-
tion). Default editor is ed (see ed(1)).
Exit from without changing the mailbox. No messages are saved in the mbox (see also
Quit from the current file of messages and read in the specified file.
Several special characters are recognized when used as file names, and substitutions are made as follows:
the current mailbox.
the mailbox for
user.
the previous file.
the current
mbox.
Default file is the current mailbox.
Print the names of the files in the
directory set by the variable (see the subsection).
Respond to a message and record the response in a file
whose name is derived from the author of the message. Overrides the variable, if set. See also the and commands and
(see the subsection).
Respond to the first message in the
msglist, sending the message to the author of each message in the msglist. The subject line is extracted 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 and commands and (see the subsection).
Print the header summary for the specified messages.
Declare an alias for the given names.
The names are substituted when alias is used as a recipient. Useful in the file.
Prints the page of headers which includes the message specified.
The variable sets the number of headers per page (see the subsection). See also the command.
Prints a summary of commands.
Holds the specified messages in the
mailbox.
mail-commands
mail-commands
Conditional execution, where
executes the accompanying mail-commands, up to an or if the program is in send mode, and causes the accompanying mail-
commands to be executed only in receive mode. Intended for use in files.
Suppresses printing of the specified header fields
when displaying messages on the screen. Examples of header fields to ignore are and All fields are included when the
message is saved. The and commands override this command.
Prints all commands available.
No explanation is given.
Mail a message to the specified users.
Arrange for the given messages to end up in the standard
mbox save file when terminates normally. See in the subsection for a description of this file. See also the and com-
mands.
Go to next message matching
message. A msglist can be specified, but in this case the first valid message in the list is the only one used. This
is useful for jumping to the next message from a specific user since the name would be interpreted as a command in the
absence of a real command. See the discussion of msglists above for a description of possible message specifications.
Pipe messages in msglist through the specified command. Each message is treated as if it were read. If msglist is not specified, the
current message is used. If command is not specified, the command specified by the current value of the variable is
used. If msglist is specified, command must also be specified. If the variable is set, a form feed character is
inserted after each message (see the subsection).
Preserve the specified messages in the
mailbox.
Print the specified messages on the screen,
including all header fields. Overrides suppression of fields by the command.
Print the specified messages.
If is set, messages longer than the number of lines specified by the variable are paged through the command specified
by the variable. The default command is (see pg(1)), but many users prefer (see more(1); see the subsection).
Exit from storing messages that were read in mbox and unread messages in the user's system mailbox. Messages that have been
explicitly saved in a file are deleted.
Send a response to the author of each message in the
msglist. The subject line is taken from the first message. If is set to a file name, the response is saved at the end
of that file (see the subsection).
Reply to the specified message,
including all other recipients of the message. If is set to a file name, the response is saved at the end of that file
(see the subsection).
Save the specified messages in a file whose name is derived from
the author of the first message. The name of the file is based on the author's name with all network addressing
stripped off. See also the and commands and (see the subsection).
Save the specified messages in the given file,
filename. The file is created if it does not exist. The message is deleted from the mailbox when terminates unless is
set (see the subsection and the and commands).
Note: If is invoked with the option, the command performs the same function as the command.
Define a variable called
name. The variable can be given a null, string, or numeric value. by itself prints all defined variables and their
values (see the subsection for detailed descriptions of the variables).
Invoke an interactive shell (see
in the subsection).
Print the size in characters of the specified messages.
Read commands from the given file and return to command mode.
Print the top few lines of the specified messages.
If the variable is set, it is interpreted as the number of lines to print (see the subsection). The default is 5.
Touch the specified messages.
If any message in msglist is not specifically saved in a file, it is placed in the mbox upon normal termination. See
and
Print the specified messages on the screen, including all header fields.
Overrides suppression of fields by the command.
Print the specified messages.
If is set, messages longer than the number of lines specified by the variable are paged through the command specified
by the variable. The default command is but many users prefer (see the subsection).
Discard the specified alias names.
Restore the specified deleted messages.
Restores only messages that were deleted in the current mail session. If is set, the last message of those restored is
printed (see the subsection ).
Cause the specified variables to be erased.
If the variable was a shell variable imported from the execution environment, it cannot be erased.
Prints the current version and release date.
Edit the given messages with a screen editor.
The messages are placed in a temporary file and the variable is used to get the name of the editor (see the subsec-
tion).
Write the given messages on the specified file,
except for the header (the "From ..." line) and trailing blank line. Otherwise equivalent to the command.
Exit from without changing the mailbox. No messages are saved in the mbox (see also
Scroll the header display forward or backward one screen-full.
The number of headers displayed is set by the variable (see the subsection).
TILDE ESCAPES
The following commands can be used only when in input mode, by beginning a line with the tilde escape character See (in the subsection) for
changing this special character.
Escape to the shell.
Simulate end of file (terminate message input).
Perform the command-level request.
Valid only when sending a message while reading mail.
Print a summary of tilde escapes.
Insert the autograph string
into the message (see the subsection).
Insert the autograph string
into the message (see the subsection).
Add name to the blind carbon copy (Bcc) list.
Add name to the carbon copy (Cc) list.
Read in the file. See (in the subsection) for a description of this file.
Invoke the editor on the partial message.
Also see the environment variable description below.
Forward the specified messages.
The messages are inserted into the message without alteration.
Prompt for Subject line and To, Cc, and Bcc lists.
If the field is displayed with an initial value, it can be edited as if you had just typed it.
Insert the value of the named variable into the text of the message.
For example, is equivalent to
Insert the specified messages into the letter,
shifting the new text to the right one tab stop. Valid only when sending a message while reading mail.
Print the message being entered.
Quit (terminate) input mode by simulating an interrupt.
If the body of the message is not null, the partial message is saved in See the description of the environment variable
below for a description of this file.
Add name to the Reply-To list.
Read in the specified file.
If the argument begins with an exclamation point the rest of the string is assumed to be an arbitrary shell command and
is executed, with the standard output inserted into the message.
Set the subject line to
string.
Add the given names to the To list.
Invoke a preferred screen editor on the partial message.
Also see the environment variable description below.
Write the partial message onto the given file, without the header.
Exit as with except the message is not saved in dead.letter.
Pipe the body of the message through the given
command. If command returns a successful exit status, the output of the command replaces the message.
EXTERNAL INFLUENCES
Environment Variables
The following variables are internal program variables. They can be imported from the execution environment or set by the command at any
time. The command can be used to erase variables.
All network names whose login names match are treated as identical.
This causes the msglist message specifications to behave similarly. Default is See also the command and the variable.
Upon termination, append messages to the end of the
mbox file instead of inserting them at the beginning of the file. Default is
Prompt for the Bcc list after the message is entered.
Default is
Prompt for the Cc list after the message is entered.
Default is
Prompt for a subject if it is not specified on the command line with the
option. Enabled by default.
Enable automatic printing of messages after
and commands. Default is
Enable special-case treatment of exclamation points
in shell escape command lines as in Default is
Set the default character set.
If none is specified, will attempt to use the value of to look up the system default for the user's locale. If that is
unsuccessful, the default value of us-ascii will be used.
Set the default command for the
command. No default value.
Convert UUCP addresses to the specified address style. The only valid conversion currently supported is internet, which
requires a mail delivery program conforming to the RFC822 standard for electronic mail addressing. Conversion is dis-
abled by default. See also and the command-line option.
Pipe messages having more than
number lines through the command specified by the value of the variable by default (see pg(1)). Disabled by default.
The name of the file in which to save partial letters
in case of untimely interrupt or delivery errors. Default is
Enable verbose diagnostics for debugging.
Messages are not delivered. Default is
When processing input from a terminal,
interpret an ASCII period character on a line by itself as end-of-file. Default is
The command to run when the
or command is used. Default is (see ed(1)).
Set the default encoding to be used when 8-bit characters are present.
Allowable values are quoted-printable, base64 and 8bit. The short-hand q-p is also acceptable for quoted-printable.
The default value will be determined based upon the value of A value of 8bit means not to encode.
Substitute c for the escape character.
The directory for saving standard mail files.
User specified file names beginning with a plus (+) are expanded by preceding the file name with this directory name to
obtain the real file name. If directory does not start with a slash is used as a prefix. There is no default for the
variable. See also below.
Enable printing of the header summary when entering
Enabled by default.
Preserve all messages that are read in the system mailbox
instead of putting them in the standard mbox save file. Default is
Ignore interrupts while entering messages.
Useful when communicating over noisy dial-up lines. Default is
Ignore end-of-file during message input.
Input must be terminated by a period on a line by itself or by the command. Default is See also above.
When the mailbox is empty, truncate it to zero length instead of removing it. Disabled by default.
Keep messages that have been saved in other files
in the system mailbox instead of deleting them. Default is
The name of the file to save messages which have been read.
The command overrides this function, as does saving the message explicitly in another file. Default is
Usually, when a group (alias) containing the sender is expanded,
the sender is removed from the expansion. Setting this option causes the sender to be included in the group. Default
is
To add or disable MIME header when sending mail.
value can be or
The command (and options) to use when listing contents of the
directory. The default is
To disable the usage of metamail to read MIME messages,
set the value to By default the variable is not set.
When responding to a message
that was originally sent to several recipients, the other recipient addresses are normally forced to be relative to the
originating author's machine for the response. This flag disables alteration of the recipients' addresses, improving
efficiency in a network where all machines can send directly to all other machines (that is, one hop away).
Cause the files used to record outgoing messages to be located
in the directory specified by the variable. Default is See above and the and commands.
Used with the command to insert a form feed after each message sent through the pipe. Default is
The command to use as a filter for paginating output.
This can also be used to specify the pager command-line options (for example, ). Default is but many users prefer (see
pg(1) and more(1)).
Set the command-mode prompt to
string. Default is
Refrain from printing the opening message and version when entering
Default is
Record all outgoing mail in
filename. Disabled by default. See also above.
Specify address to which responses are to be sent.
Enable saving of messages in
on interrupt or delivery error. See for a description of this file. Enabled by default.
Set the number of lines in a screen-full of headers for the
command.
Alternate command for delivering messages.
Default is (see mail(1)).
Wait for background mailer to finish before returning.
Default is
The name of a preferred command interpreter.
Default is the user's login program (see passwd(4), shells(4), and chsh(1)). Note: in the unusual case that a user's
login program is a script file from which is executed, rather than a shell, then requires that the user explicitly set
in his or her file.
When displaying the header summary and the message is from you,
print the recipient's name instead of the author's name.
The variable that is inserted into the text of a message when the
(autograph) command is given. No default (see also in the section).
The variable inserted into the text of a message when the
command is given. No default (see also in the section).
When is set, various commands use the line instead of the default line.
The number of lines of header to print with the
command. Default is 5.
The name of a preferred screen editor.
Default is (see vi(1)).
The following are environment variables taken from the execution environment and are not alterable within
The user's home directory.
This is usually the current directory immediately after login.
The name of the initial mailbox file to be read.
By default, the mailbox is set to This environment variable overrides the default setting and causes to open the
mailbox specified by the environment variable.
The name of the mailer start-up file.
Default is
and influence when the command interpreter (see the environment variable) is invoked. To determine the behavior of and
see the corresponding shell manpage for the applicable command interpreter.
determines the format and contents
of the date and time strings displayed. If is not specified in the environment, or is set to the empty string, the
value of is used as a default. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is
used instead of If any internationalization variable contains an invalid setting, behaves as if all internationaliza-
tion variables are set to "C". See environ(5).
When set, the environment variable specifies a directory to be used for temporary files, overriding the default directory
International Code Set Support
Single- and multibyte character code sets are supported within mail text. Headers are restricted to characters from the 7-bit USASCII
character code set (see ascii(5)).
WARNINGS
Where command is shown as valid, arguments are not always allowed. Experimentation is recommended.
Internal variables imported from the execution environment cannot be
The full internet addressing is not fully supported by The new internationalization standards need some time to settle down.
the standard mail delivery program, treats a line consisting solely of a dot as the end of the message.
Using two separate mail programs to access the same mail file simultaneously (usually inadvertently from two separate windows) can cause
unpredictable results.
Arguments containing multiple words must be enclosed in quotes. Otherwise they may be interpreted incorrectly.
FILES
Post office directory (mode 775, group ID
System mailbox for user (mode 660, owned by user, group ID
Personal start-up file
Global start-up file
Secondary storage file
Temporary files
SEE ALSO
chsh(1), echo(1), ed(1), lp(1), ls(1), mail(1), more(1), pg(1), sh(1), vi(1), passwd(4), shells(4), ascii(5), environ(5), lang(5).
STANDARDS CONFORMANCE
For more information about also refer to the section in the UNIX 95 standard document specification.
mailx(1)