Regular commands are of the form
[ command ] [ message-list ] [ arguments ]
In input mode, commands are recognized by the escape
character, tilde(~), and lines not treated as commands are taken as
input for the message. If no command is specified in command mode,
next is assumed. The following is a complete list of mailx
commands:
!shell-command
Escape to the shell. See SHELL in ENVIRONMENT
VARIABLES.
# comment
NULL command (comment). Useful in mailrc
files.
=
Print the current message number.
?
Prints a summary of commands.
alias alias name ...
group alias name ...
Declare an alias for the given names. The names are
substituted when alias is used as a recipient. Useful in the
mailrc file. With no arguments, the command displays the list of
defined aliases.
alternates name ...
Declare 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, print the current list of alternate
names. See also allnet in Internal Variables.
cd [directory]
chdir [directory]
Change directory. If directory is not specified,
$HOME is used.
copy [file]
copy [message-list] file
Copy messages to the file without marking the messages as
saved. Otherwise equivalent to the save command.
Copy [message-list]
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 Save command.
delete [message-list]
Delete messages from the mailbox. If
autoprint is set, the next message after the last one deleted is
printed (see Internal Variables).
discard [header-field...]
ignore [header-field...]
Suppress printing of the specified header fields when
displaying messages on the screen. Examples of header fields to ignore are
Status and Received. The fields are included when the message is
saved, unless the alwaysignore variable is set. The More,
Page, Print, and Type commands override this command. If
no header is specified, the current list of header fields being ignored is
printed. See also the undiscard and unignore commands.
dp [message-list]
dt [message-list]
Delete the specified messages from the mailbox and
print the next message after the last one deleted. Roughly equivalent to a
delete command followed by a print command.
echo string ...
Echo the given strings (like
echo(1)).
edit [message-list]
Edit the given messages. Each message is placed in a
temporary file and the program named by the
EDITOR variable is invoked
to edit it (see ENVIRONMENT VARIABLES). Default editor is
ed(1).
expandaddr
Causes recipient addresses to be expanded based on the
discussion in the section Sending Mail. Note that enabling this option
allows for addresses that can cause arbitrary command execution by starting
with the | character.
exit
xit
Exit from mailx, without changing the
mailbox. No messages are saved in the mbox (see also
quit).
field [message-list] header-file
Display the value of the header field in the specified
message.
file [file]
folder [file]
Quit from the current file of messages and read in the
specified file. Several special characters are recognized when used as file
names:
%
the current mailbox.
%user
the mailbox for user.
#
the previous mail file.
&
the current mbox.
+file
The named file in the folder directory (listed in
the folder variable).
With no arguments, print the name of the current mail file, and
the number of messages and characters it contains.
folders
Print the names of the files in the directory set by the
folder variable (see Internal Variables).
Followup [message]
Respond to a message, recording the response in a file
whose name is derived from the author of the message. Overrides the
record variable, if set. If the replyall variable is set, the
actions of Followup and followup are reversed. See also the
followup, Save, and Copy commands and outfolder in
Internal Variables, and the Starting Mail section in USAGE
above.
followup [message-list]
Respond to the first message in the message-list,
sending the message to the author of each message in the 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. If the
replyall variable is set, the actions of followup and
Followup are reversed. See also the Followup, Save, and
Copy commands and outfolder in Internal Variables, and
the Starting Mail section in USAGE above.
from [message-list]
Print the header summary for the specified messages. If
no messages are specified, print the header summary for the current
message.
group alias name ...
alias alias name ...
Declare an alias for the given names. The names are
substituted when alias is used as a recipient. Useful in the
mailrc file.
headers [message]
Print the page of headers which includes the message
specified. The screen variable sets the number of headers per page (see
Internal Variables). See also the z command.
help
Print a summary of commands.
hold [message-list]
preserve [message-list]
Hold the specified messages in the mailbox.
if s | r | t
mail-commands
else
mail-commands
endif
Conditional execution, where s executes following
mail-commands, up to an else or endif, if the program is
in send mode, r causes the mail-commands to be executed
only in receive mode, and t causes the mail-commands to
be executed only if mailx is being run from a terminal. Useful in the
mailrc file.
inc
Incorporate messages that arrive while you are reading
the system mailbox. The new messages are added to the message list in the
current mail session. This command does not commit changes made during
the session, and prior messages are not renumbered.
ignore [header-field ...]
discard [header-field ...]
Suppress printing of the specified header fields when
displaying messages on the screen. Examples of header fields to ignore are
Status and Cc. All fields are included when the message is
saved. The More, Page, Print and Type commands
override this command. If no header is specified, the current list of header
fields being ignored is printed. See also the undiscard and
unignore commands.
list
Print all commands available. No explanation is
given.
load
[message] file The specified message is
replaced by the message in the named file. file should contain a single
mail message including mail headers (as saved by the save
command).
mail recipient ...
Mail a message to the specified recipients.
Mail recipient
Mail a message to the specified recipients, and record it
in a file whose name is derived from the author of the message. Overrides the
record variable, if set. See also the Save and Copy
commands and outfolder in Internal Variables.
mbox [message-list]
Arrange for the given messages to end up in the standard
mbox save file when mailx terminates normally. See MBOX
in ENVIRONMENT VARIABLES for a description of this file. See also the
exit and quit commands.
more [message-list]
page [message-list]
Print the specified messages. If
crt is set, the
messages longer than the number of lines specified by the
crt variable
are paged through the command specified by the
PAGER variable. The
default command is
pg(1) or if the
bsdcompat variable is set,
the default is
more(1). See ENVIRONMENT VARIABLES. Same as the
print and
type commands.
More [message-list]
Page [message-list]
Print the specified messages on the screen, including all
header fields. Overrides suppression of fields by the ignore command.
Same as the Print and Type commands.
new [message-list]
New [message-list]
unread [message-list]
Unread
[message-list] Take a message list and mark each
message as not having been read.
next [message]
Go to the next message matching message. If
message is not supplied, this command finds the next message that was not
deleted or saved. A message-list may 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
taken as a command in the absence of a real command. See the discussion of
message-list above for a description of possible message
specifications.
pipe [message-list] [shell-command]
| [message-list] [shell-command]
Pipe the message through the given shell-command.
The message is treated as if it were read. If no arguments are given, the
current message is piped through the command specified by the value of the
cmd variable. If the page variable is set, a form feed character
is inserted after each message (see Internal Variables).
preserve [message-list]
hold [message-list]
Preserve the specified messages in the
mailbox.
print [message-list]
type [message-list]
Print the specified messages. If
crt is set, the
messages longer than the number of lines specified by the
crt variable
are paged through the command specified by the
PAGER variable. The
default command is
pg(1) or if the
bsdcompat variable is set,
the default is
more(1). See ENVIRONMENT VARIABLES. Same as the
more and
page commands.
Print [message-list]
Type [message-list]
Print the specified messages on the screen, including all
header fields. Overrides suppression of fields by the ignore command.
Same as the More and Page commands.
put [file]
put [message-list] file
Save the specified message in the given file. Use the
same conventions as the print command for which header fields are
ignored.
Put [file]
Put [message-list] file
Save the specified message in the given file. Overrides
suppression of fields by the ignore command.
quit
Exit from mailx, storing messages that were read
in mbox and unread messages in the mailbox. Messages that have
been explicitly saved in a file are deleted unless the keepsave
variable is set.
reply [message-list]
respond [message-list]
replysender [message-list]
Send a response to the author of each message in the
message-list. The subject line is taken from the first message. If
record is set to a file, a copy of the reply is added to that file. If
the replyall variable is set, the actions of
Reply/Respond and reply/respond are reversed. The
replysender command is not affected by the replyall variable,
but sends each reply only to the sender of each message. See the Starting
Mail section in USAGE above.
Reply [message]
Respond [message]
replyall [message]
Reply to the specified message, including all other
recipients of that message. If the variable record is set to a file, a
copy of the reply added to that file. If the replyall variable is set,
the actions of Reply/Respond and reply/respond are
reversed. The replyall command is not affected by the replyall
variable, but always sends the reply to all recipients of the message. See the
Starting Mail section in USAGE above.
retain
Add the list of header fields named to the retained
list. Only the header fields in the retain list are shown on your terminal
when you print a message. All other header fields are suppressed. The set of
retained fields specified by the retain command overrides any list of
ignored fields specified by the ignore command. The Type and
Print commands can be used to print a message in its entirety. If
retain is executed with no arguments, it lists the current set of
retained fields.
Save [message-list]
Save 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 addressing stripped off. See also the
Copy, followup, and Followup commands and
outfolder in Internal Variables.
save [file]
save [message-list] file
Save the specified messages in the given file. The file
is created if it does not exist. The file defaults to mbox. The message
is deleted from the mailbox when mailx terminates unless
keepsave is set (see also Internal Variables and the exit
and quit commands).
set
set variable
set variable=string
set variable=number
Define a
variable. To assign a
value to
variable, separate the variable name from the value by an `
='
(there must be no space before or after the `
='). A variable may be
given a null, string, or numeric
value. To embed SPACE characters
within a
value, enclose it in quotes.
With no arguments, set displays all defined variables and
any values they might have. See Internal Variables for a description
of all predefined mail variables.
shell
Invoke an interactive shell. See also SHELL in
ENVIRONMENT VARIABLES.
size [message-list]
Print the size in characters of the specified
messages.
source file
Read commands from the given file and return to command
mode.
top [message-list]
Print the top few lines of the specified messages. If the
toplines variable is set, it is taken as the number of lines to print
(see Internal Variables). The default is 5.
touch [message-list]
Touch the specified messages. If any message in
message-list is not specifically saved in a file, it is placed in the
mbox, or the file specified in the MBOX environment variable,
upon normal termination. See exit and quit.
Type [message-list]
Print [message-list]
Print the specified messages on the screen, including all
header fields. Overrides suppression of fields by the ignore
command.
type [message-list]
print [message-list]
Print the specified messages. If
crt is set, the
messages longer than the number of lines specified by the
crt variable
are paged through the command specified by the
PAGER variable. The
default command is
pg(1). See ENVIRONMENT VARIABLES.
unalias [alias] ...
ungroup [alias] ...
Remove the definitions of the specified aliases.
undelete [message-list]
Restore the specified deleted messages. Will only restore
messages deleted in the current mail session. If autoprint is set, the
last message of those restored is printed (see Internal
Variables).
undiscard [header-field...]
unignore [header-field...]
Remove the specified header fields from the list being
ignored. If no header fields are specified, all header fields are removed from
the list being ignored.
unretain [header-field...]
Remove the specified header fields from the list being
retained. If no header fields are specified, all header fields are removed
from the list being retained.
unread [message-list]
Unread [message-list] Same as the new command.
unset variable...
Erase the specified variables. If the variable was
imported from the environment (that is, an environment variable or exported
shell variable), it cannot be unset from within mailx.
version
Print the current version and release date of the
mailx utility.
visual [message-list]
Edit the given messages with a screen editor. Each
messages is placed in a temporary file and the program named by the
VISUAL variable is invoked to edit it (see ENVIRONMENT VARIABLES).
Notice that the default visual editor is vi.
write [message-list] file
Write the given messages on the specified file, minus the
header and trailing blank line. Otherwise equivalent to the save
command.
xit
exit
Exit from mailx, without changing the
mailbox. No messages are saved in the mbox (see also
quit).
z[+|−]
Scroll the header display forward or backward one
screen−full. The number of headers displayed is set by the
screen variable (see Internal Variables).
The following tilde escape commands can be used when composing
mail to send. These may be entered only from input mode, by beginning
a line with the tilde escape character (~). See escape in Internal
Variables for changing this special character. The escape character can
be entered as text by typing it twice.
~!shell-command
Escape to the shell. If present, run
shell-command.
~.
Simulate end of file (terminate message input).
~:mail-command
~_mail-command
Perform the command-level request. Valid only when
sending a message while reading mail.
~?
Print a summary of tilde escapes.
~A
Insert the autograph string Sign into the message
(see Internal Variables).
~a
Insert the autograph string sign into the message
(see Internal Variables).
~b name ...
Add the names to the blind carbon copy
(Bcc) list. This is like the carbon copy (Cc) list, except that
the names in the Bcc list are not shown in the header of the mail
message.
~c name ...
Add the names to the carbon copy (Cc)
list.
~d
Read in the dead-letter file. See DEAD in
ENVIRONMENT VARIABLES for a description of this file.
~e
Invoke the editor on the partial message. See also
EDITOR in ENVIRONMENT VARIABLES.
~f [message-list]
Forward the specified message, or the current message
being read. Valid only when sending a message while reading mail. The messages
are inserted into the message without alteration (as opposed to the ~m
escape).
~F [message-list]
Forward the specified message, or the current message
being read, including all header fields. Overrides the suppression of fields
by the ignore command.
~h
Prompt for Subject line and To, Cc,
and Bcc lists. If the field is displayed with an initial value, it may
be edited as if you had just typed it.
~i variable
Insert the value of the named variable into the text of
the message. For example, ~A is equivalent to `~i Sign.'
Environment variables set and exported in the shell are also accessible by
~i.
~m [message-list]
Insert the listed messages, or the current message being
read into the letter. Valid only when sending a message while reading mail.
The text of the message is shifted to the right, and the string contained in
the indentprefix variable is inserted as the leftmost characters of
each line. If indentprefix is not set, a TAB character is inserted into
each line.
~M [message-list]
Insert the listed messages, or the current message being
read, including the header fields, into the letter. Valid only when sending a
message while reading mail. The text of the message is shifted to the right,
and the string contained in the indentprefix variable is inserted as
the leftmost characters of each line. If indentprefix is not set, a TAB
character is inserted into each line. Overrides the suppression of fields by
the ignore command.
~p
Print the message being entered.
~q
Quit from input mode by simulating an interrupt. If the
body of the message is not null, the partial message is saved in
dead-letter. See DEAD in ENVIRONMENT VARIABLES for a description
of this file.
~R
Mark message for return receipt.
~r file
~< file
~< ! shell-command
Read in the specified file. If the argument begins with
an exclamation point (!), the rest of the string is taken as an arbitrary
shell command and is executed, with the standard output inserted into the
message.
~s string ...
Set the subject line to string.
~t name ...
Add the given names to the To list.
~v
Invoke a preferred screen editor on the partial message.
The default visual editor is
vi(1). See also
VISUAL in
ENVIRONMENT VARIABLES.
~w file
Write the message into the given file, without the
header.
~x
Exit as with ~q except the message is not saved in
dead-letter.
~| shell-command
Pipe the body of the message through the given
shell-command. If the shell-command returns a successful exit
status, the output of the command replaces the message.
The following variables are internal variables. They may be
imported from the execution environment or set using the set command
at any time. The unset command may be used to erase variables.
allnet
All network names whose last component (login name) match
are treated as identical. This causes the message-list message
specifications to behave similarly. Disabled by default. See also the
alternates command and the metoo and fuzzymatch
variables.
alwaysignore
Ignore header fields with ignore everywhere, not
just during print or type. Affects the save, Save,
copy, Copy, top, pipe, and write commands,
and the ~m and ~f tilde escapes. Enabled by default.
append
Upon termination, append messages to the end of the
mbox file instead of prepending them. Although disabled by default,
append is set in the system startup file (which can be suppressed with
the -n command line option).
appenddeadletter
Append to the deadletter file rather than overwrite it.
Although disabled by default, appenddeadletter is frequently set in the
system startup file. See Starting Mail in USAGE above.
askbcc
Prompt for the Bcc list after the Subject
is entered if it is not specified on the command line with the -b
option. Disabled by default.
askcc
Prompt for the Cc list after the Subject is
entered if it is not specified on the command line with the -c option.
Disabled by default.
asksub
Prompt for subject if it is not specified on the command
line with the -s option. Enabled by default.
autoinc
Automatically incorporate new messages into the current
session as they arrive. This has an affect similar to issuing the inc
command every time the command prompt is displayed. Disabled by default, but
autoinc is set in the default system startup file for mailx; it
is not set for /usr/ucb/mail or /usr/ucb/Mail.
autoprint
Enable automatic printing of messages after delete
and undelete commands. Disabled by default.
bang
Enable the special-casing of exclamation points (!) in
shell escape command lines as in
vi(1). Disabled by default.
bsdcompat
Set automatically if
mailx is invoked as
mail or
Mail. Causes
mailx to use
/etc/mail/Mail.rc as the system startup file. Changes the default pager
to
more(1).
cmd=shell-command
Set the default command for the pipe command. No
default value.
conv=conversion
Convert
uucp addresses to the specified address
style, which can be either:
internet
This requires a mail delivery program conforming to the
RFC822 standard for electronic mail addressing.
optimize
Remove loops in
uucp(1C) address paths (typically
generated by the
reply command). No rerouting is performed;
mail
has no knowledge of
UUCP routes or connections.
Conversion is disabled by default. See also sendmail(8) and
the -U command-line option.
crt[=number]
Pipe messages having more than
number lines
through the command specified by the value of the
PAGER variable (
pg(1) or
more(1) by default). If
number is not specified,
the current window size is used. Disabled by default.
debug
Enable verbose diagnostics for debugging. Messages are
not delivered. Disabled by default.
dot
Take a period on a line by itself, or EOF during
input from a terminal as end-of-file. Disabled by default, but dot is
set in the system startup file (which can be suppressed with the -n
command line option).
fcc
By default, mailx will treat any address
containing a slash ("/") character as a local "send to
file" address. By unsetting this option, this behavior is disabled.
Enabled by default.
flipr
Reverse the effect of the followup/Followup
and reply/Reply command pairs. If both flipr and
replyall are set, the effect is as if neither was set.
from
Extract the author listed in the header summary from the
From: header instead of the UNIX From line. Enabled by
default.
fuzzymatch
The from command searches for messages from the
indicated sender. By default, the full sender address must be specified. By
setting this option, only a sub-string of the sender address need be
specified. Disabled by default.
escape=c
Substitute c for the ~ escape character. Takes
effect with next message sent.
folder=directory
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 (/), $HOME is prepended to
it. There is no default for the folder variable. See also
outfolder below.
header
Enable printing of the header summary when entering
mailx. Enabled by default.
hold
Preserve all messages that are read in the mailbox
instead of putting them in the standard mbox save file. Disabled by
default.
ignore
Ignore interrupts while entering messages. Handy for
noisy dial-up lines. Disabled by default.
ignoreeof
Ignore end-of-file during message input. Input must be
terminated by a period (.) on a line by itself or by the ~. command.
See also dot above. Disabled by default.
indentprefix=string
When indentprefix is set, string is used to
mark indented lines from messages included with ~m. The default is a
TAB character.
keep
When the mailbox is empty, truncate it to zero
length instead of removing it. Disabled by default.
iprompt=string
The specified prompt string is displayed before each line
on input is requested when sending a message.
keepsave
Keep messages that have been saved in other files in the
mailbox instead of deleting them. Disabled by default.
makeremote
When replying to all recipients of a message, if an
address does not include a machine name, it is assumed to be relative to the
sender of the message. Normally not needed when dealing with hosts that
support RFC822.
metoo
If your login appears as a recipient, do not delete it
from the list. Disabled by default.
mustbang
Force all mail addresses to be in bang format.
onehop
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). Disabled by default.
outfolder
Locate the files used to record outgoing messages in the
directory specified by the folder variable unless the path name is
absolute. Disabled by default. See folder above and the Save,
Copy, followup, and Followup commands.
page
Used with the pipe command to insert a form feed
after each message sent through the pipe. Disabled by default.
pipeignore
Omit ignored header when outputting to the pipe
command. Although disabled by default, pipeignore is frequently set in
the system startup file. See Starting Mail in USAGE above.
postmark
Your "real name" to be included in the From
line of messages you send. By default this is derived from the comment field
in your
passwd(5) file entry.
prompt=string
Set the command mode prompt to string.
Default is "? ", unless the bsdcompat variable is set,
then the default is "&".
quiet
Refrain from printing the opening message and version
when entering mailx. Disabled by default.
record=file
Record all outgoing mail in file. Disabled by
default. See also outfolder above.
replyall
Reverse the effect of the reply and Reply
and followup and Followup commands. Although set by default,
replayall is frequently unset in the system startup file. See
flipr and Starting Mail in USAGE above.
returnaddr=string
The default sender address is that of the current user.
This variable can be used to set the sender address to any arbitrary value.
Set with caution.
save
Enable saving of messages in dead-letter on
interrupt or delivery error. See DEAD for a description of this file.
Enabled by default.
screen=number
Sets the number of lines in a screen-full of headers for
the
headers command.
number must be a positive number.
The default is set according to baud rate or window size. With a
baud rate less than 1200, number defaults to 5, if baud
rate is exactly 1200, it defaults to 10. If you are in a
window, number defaults to the default window size minus 4.
Otherwise, the default is 20.
sendmail=shell-command
Alternate command for delivering messages. Note:
In addition to the expected list of recipients, mail also passes the
-i and -m, flags to the command. Since these flags are not
appropriate to other commands, you may have to use a shell script that strips
them from the arguments list before invoking the desired command. Default is
/usr/bin/rmail.
sendwait
Wait for background mailer to finish before returning.
Disabled by default.
showname
Causes the message header display to show the sender's
real name (if known) rather than their mail address. Disabled by default, but
showname is set in the /etc/mail/mailx.rc system startup file
for mailx.
showto
When displaying the header summary and the message is
from you, print the recipient's name instead of the author's name.
sign=string
The variable inserted into the text of a message when the
~a (autograph) command is given. No default (see also
~i in
Tilde Escapes).
`
Sign=string
The variable inserted into the text of a message when the
~A command is given. No default (see also ~i in Tilde
Escapes).
toplines=number
The number of lines of header to print with the
top command. Default is 5.
verbose
translate
The name of a program to translate mail addresses. The
program receives mail addresses as arguments. The program produces, on the
standard output, lines containing the following data, in this order:
- o
- the postmark for the sender (see the postmark variable)
- o
- translated mail addresses, one per line, corresponding to the program's
arguments. Each translated address will replace the corresponding address
in the mail message being sent.
- o
- a line containing only "y" or "n". if the line
contains "y" the user will be asked to confirm that the message
should be sent.
The translate program will be invoked for each mail message to be sent. If the
program exits with a non-zero exit status, or fails to produce enough output,
the message is not sent.