NAME
mailx, Mail - Sends and receives mail
SYNOPSIS
Sending Mail
mailx [-inNv] [-s subject] [user ...]
Mail [-inNv] [-s subject] [user ...]
Handling Mail
mailx [-dinNv] -f file
Mail [-dinNv] -f file
mailx [-dinNv] -u user
Mail [-dinNv] -u user
The mailx and Mail commands allow you to read, write, send,
receive, store, and discard mail messages.
FLAGS
-d Causes the mailx command to display debugging informa-
tion. Messages are not sent while in debug mode.
-e Tests for the presence of mail. The mailx command
prints nothing and exits with a successful return code
if there is mail to read.
-f file
Reads in the contents of your mbox or the specified file
for processing. When you quit, mailx writes undeleted
messages back to this file.
-F Records the message in a file named after the first
recipient. Overrides the record option, if set.
-hnumber
Specifies the number of network "hops" made so far.
This is provided for network software to avoid infinite
loops.
-H Prints header summary only.
-i Ignores tty Interrupt signals. Useful when using mailx
on noisy phone lines.
-n Inhibits the reading of the /usr/share/lib/Mail.rc file.
-N Suppresses the initial printing of headers.
-raddress
Passes address to the network delivery software. All
tilde commands are disabled.
-s subject
Specifies a subject for a message to be created.
-u user
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.
-v Puts mailx into verbose mode. Details of delivery are
displayed on the user's terminal.
DESCRIPTION
The mailx and Mail commands allow you to do the following:
o Compose a message and send it.
o Receive a message and look at it.
o Store received messages in your mailbox or in folders.
o 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 particular 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 .mailrc 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 associated 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 personal
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 com-
mand 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
folder.
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 message using an editor such as ed.
When you are finished with the message, 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
the message.
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 environment 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 without flags 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.
Reading Incoming Mail
To receive and read incoming mail, enter mailx with no argu-
ments:
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 message 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 fol-
lows:
M The message will be stored in your personal mailbox.
N The message is new.
P The message will be held (preserved) in your system
mailbox.
R You have read the message.
U The message is unread. The message was listed in the
mailbox before, but you have not looked at the contents
of the message.
* You have saved or written the message to a file or
folder.
no indicator
The message was read, but was not deleted or saved.
The other fields in the listing (in order) represent:
Message Number
The number that mailbox subcommands use to refer to the
message.
Address
User address of the sender.
Date
Date the message was received, including day of the
week, month, day, and time.
Size
Size of the message in number of lines and characters,
including header information.
Subject
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 mailbox. 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 mailbox prompt.
Many mailbox subcommands allow you to specify groups of mes-
sages upon which to perform the subcommand. Subcommands
that allow groups of messages use the argument message_list
in the command format. For example, 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:
o One or more message numbers separated by spaces. For
example:
& f 1 2 4 7
o 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
o An example of one or more addresses separated by spaces
to apply the subcommand to messages received from those
addresses follows:
& 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. Therefore, the request for
address amy matches all of the following addresses (and
many others):
-- amy
-- AmY
-- amy@zeus
-- hamy
o 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 Sub-
ject: field contains the letters meet in uppercase or
lowercase. The characters entered for a match pattern
do not have to match the Subject: field exactly. They
must only be contained in the Subject: field of the
messages in either uppercase or lowercase. Therefore,
the request for subject meet matches all of the follow-
ing 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:
d Deleted messages
n New messages
o Old messages
r Read messages
u Unread messages
All commands that take a message list will default to the
current message 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 subcommands. The subcommand abbrevia-
tion in parentheses can be used instead of the full subcom-
mand name.
= Echoes the number of the current message.
# Allows you to write comments in mail script files.
-n Goes to the previous 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.
!shell_command
Executes shell_command.
alias [alias] [address | list] (a)
Displays all currently defined aliases. With the argu-
ment of a previously defined alias, displays the expan-
sion of the alias. With two arguments (alias and
address | list), creates a new alias or changes an old
alias. Identical to the group subcommand.
alternates alternate_list (alt)
Informs mailx that the addresses listed in
alternate_list all refer to you. The alternates subcom-
mand is useful if you have accounts on several machines.
Then, when you reply to messages, mailx does not send a
copy of the message to any of the addresses give in
alternate_list. If you enter the alternates subcommand
with no argument, mailx displays the current set of
alternate names.
chdir directory (cd, ch)
Changes your working directory to directory. If no
directory is given, it changes to your login directory.
copy [message_list] file (c, co)
Appends each message in message_list in turn to the end
of file. Displays the filename in quotes, followed by
the line count and character count, on your terminal.
Does not mark the appended messages for deletion when
you quit.
Copy [message_list] (C)
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 subcommand.
delete [message_list] (d)
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. How-
ever, you can restore messages that you have deleted
while in the same mailbox session (see the undelete sub-
command). If you delete a message and either change to
another mailbox or quit the mailbox with the quit sub-
command, the deleted message cannot be recalled.
discard [field_list] (di)
Identical to the ignore subcommand.
dp Deletes the current message and displays the next mes-
sage. If there is no next message, mailx displays the
message, at EOF.
dt Identical to the dp subcommand.
echo string (ec)
Displays the character string string on the command
line.
edit [message_list] (e)
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.
exit (ex or x)
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 subcom-
mand.
file [name] (fi)
Identical to the folder subcommand.
folder [name] (fold)
Switches to a new mail file or folder. With no argu-
ments, 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 mes-
sages 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).
+name
Refers to a file in your folder directory (deter-
mined by the value of the folder option; see Ena-
bling and Disabling Options).
folders
Lists the names of the folders in your folder directory
(see the folder option in Enabling and Disabling
Options).
followup [message] (fo)
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 Fol-
lowup, Save, and Copy subcommands and the outfolder
option.)
Followup [message_list] (F)
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
outfolder option.)
from [message_list] (f)
Displays the headers of messages in message_list.
group (g)
Identical to the alias subcommand.
headers [message_list] (h)
Lists the headers 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 information
about the rest of the messages, use the h subcommand
with a message number that is in the next range of mes-
sages, or use the z subcommand to change the current
message group.
help
Displays a brief summary of mailbox subcommands. Ident-
ical to the ? (question mark) subcommand.
hold [message_list] (ho)
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 subcommand.
Identical to the preserve subcommand.
if condition (i)
else (el)
endif (en)
Construction for conditional execution of mailx subcom-
mands. Subcommands following if are executed if condi-
tion 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).
ignore [field_list] (ig)
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 sub-
commands. Use this subcommand to suppress machine-
generated header fields. Use the Type and Print subcom-
mands to print a message in its entirety, including
ignored fields. If ignore is executed with no argu-
ments, it lists the current set of ignored fields.
Identical to the discard subcommand.
list (l)
Displays a list of valid mailx subcommands.
local
Lists other names for the local host.
mail address_list (m)
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.
mbox [message_list] (mb)
Indicates that the messages 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.
more [message_list] (mo)
Displays the messages in message_list using the defined
pager program to control the display to the screen.
Identical to the page subcommand.
More [message_list] (Mo)
Like more, but also displays ignored header fields.
(See more and ignore.)
new [message_list]
Marks each message in message_list as not having been
read. Identical to the New, unread, and Unread subcom-
mands.
New [message_list]
Marks each message in message_list as not having been
read. Identical to the new, unread, and Unread subcom-
mands.
next [message] (n)
Makes the next message in the mailbox the current mes-
sage, and displays that message. With an argument list,
it displays the next matching message.
page [message_list] (pa)
Displays the messages in message_list using the defined
pager program to control the display to the screen.
Identical to the more subcommand.
Page [message_list] (Pa)
Like the page subcommand, but also displays ignored
header fields. Identical to the More subcommand.
pipe [message_list] [shell_command] (pi)
| [message_list] [shell_command]
Pipes the message through shell_command. The message is
treated as if it were read. If no arguments are given,
the current message is piped through the command speci-
fied by the value of the cmd option. If the page option
is set, a formfeed character is inserted after each mes-
sage.
preserve (pre)
Identical to the hold subcommand.
print [message_list] (p)
Displays the messages in message_list. Identical to the
type subcommand.
Print [message_list] (P)
Like print, but also displays ignored header fields.
(See print and ignore.) Identical to the Type subcom-
mand.
quit (q)
Ends the session and returns to the shell. All messages
that were not deleted or saved are stored in your per-
sonal 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 flag, then the
edit file is saved with the changes. If the edit file
cannot be saved, mailx does not exit. Use the exit sub-
command to exit without saving the changes.
reply [message] (r)
Allows you to reply to the sender of message and to all
others who received copies of message. Identical to the
respond subcommand.
Reply [message] (R)
Allows you to reply only to the sender of message.
Identical to the Respond subcommand.
respond [message]
Allows you to reply to the sender of message and to all
others who received copies of message. Identical to the
reply subcommand.
Respond [message]
Allows you to reply only to the sender of message.
Identical to the Reply subcommand.
retain [field_list]
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 sub-
commands. Use this subcommand to define which header
fields you want displayed. Use the Type and Print sub-
commands 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.
save [message_list] file (s)
Saves message_list, including 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 complete.
If you save a message to a file, that message is not
returned to the system mailbox nor saved in your per-
sonal mailbox when you quit the mailx command. If a
filename is not specified, the mailx command saves the
messages in your personal mailbox.
Save [message_list] (S)
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 addressing stripped off. (See also the Copy,
followup, and Followup subcommands, and the outfolder
option.)
set [option_list | option=value] (se)
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.)
shell (sh)
Invokes an interactive version of the shell.
size [message_list] (si)
Displays the sizes in lines and characters of the mes-
sages in message_list.
source file (so)
Reads and executes the mailx commands from file.
top [message_list] (to)
Displays the top few lines of the messages specified by
message_list. The number of lines displayed is deter-
mined by the valued option toplines and defaults to 5.
touch [message_list] (tou)
Marks the messages in message_list to be moved from your
system mailbox to your personal 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 mes-
sage.
type [message_list] (t)
Displays the messages in message_list. Identical to the
print subcommand.
Type [message_list] (T)
Like type, but also displays ignored header fields.
(See type and ignore.) Identical to the Print subcom-
mand.
unalias alias_list
Deletes the specified alias names. If a specified alias
does not exist, the results are unspecified.
undelete [message_list] (u)
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.
unread [message_list] (U)
Marks each message in message_list as not having been
read. Identical to the new, New, and Unread subcom-
mands.
Unread [message_list]
Marks each message in message_list as not having been
read. Identical to the new, New, and unread subcom-
mands.
unset [option_list] (uns)
Discards the values of the options specified in
option_list. This action is the inverse of the set sub-
command.
version (ve)
Displays the version banner for the mailx command.
visual [message_list] (v)
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 editor, any
changes made during the editing session are saved back
to the messages in message_list.
write [message_list] file (w)
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 message headers
in the file.
xit (x)
Identical to the exit subcommand.
z [+] [-]
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 give, then headers in the next
group are shown. If a - argument is given, the headers
in the previous group are shown.
Sending Mail
You can use the mailx command in one of two ways to send
information. You can use the mailx command's built-in edi-
tor 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 favor-
ite editor, a source file for a program you have written, or
any other file in text format.
The mailx command provides a line-oriented editor for com-
posing messages. 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 sub-
command 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 reci-
pients 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.
~!command
Executes the shell command and returns to the message.
~. Simulates End-of-File (terminates message input).
~:command
~_command
Performs the command-level request. Valid only when
sending a message while reading mail.
~a Inserts the autograph string from the sign= option into
the message.
~A Inserts the autograph string from the Sign= option into
the message.
~b address_list
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.
~c address_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.
~C Dumps core.
~d Appends the file dead.letter from your home directory to
the current end of the message.
~e 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.
~f message_list
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 subcommand. The ~f subcommand
works only if you entered the mail editor from the mail-
box prompt using the mail subcommand, the reply subcom-
mand, or the Reply subcommand.
~F message_list
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 com-
mands.
~h 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.
~i string
Inserts the value of the named option into the text of
the message. For example, ~A is equivalent to ~i Sign.
~m message_list
Reads message_list into the current message for refer-
ence purposes. 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 mail-
box prompt using the mail subcommand, the reply subcom-
mand, or the Reply subcommand. If no messages are
specified, it reads the current message.
~M message_list
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 com-
mands.
~p Displays the message as it currently exists, prefaced by
the message header fields.
~q or ~Q
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 previous contents of the
dead.letter file are overwritten by the partially com-
pleted message.
You can also quit the editor by using the Interrupt key
sequence.
~<file
~<!shell_command
~r file
Reads the named file into the message. If the argument
begins with !, the rest of the string is taken as an
arbitrary system command and is executed, with the stan-
dard output inserted into the message.
~s string
Changes the Subject: field to the phrase specified in
string.
~t address_list
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.
~v Invokes the visual editor using the text of the current
message as the input file. (This editor can be defined
using the set VISUAL= 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.
~w file
Writes the message to the named file.
~x Exits as with ~q, except the message is not saved in
dead.letter.
~|command or ~^command
Pipes the message through command as a filter. If com-
mand 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 mes-
sage.
~~ Allows you to use the ~ (tilde) character in a message
without it being interpreted 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 characteris-
tics 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, followup, 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 shor-
tens how you address mail, and the ignore subcommand
suppresses message header fields.
Enabling and Disabling Options
The following are environment variables taken from the exe-
cution environment and are not alterable within mailx:
HOME=directory
The pathname of the user's home directory.
MAILRC=file
The name of the start-up file. The default is
$HOME/.mailrc.
Use the set subcommand to enable options and the unset sub-
command 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 follows:
unset [option_list]
The following is a list of binary options (those that can be
set or unset):
append
Causes messages saved in mbox to be appended (added to
the end) rather than prepended (added to the beginning).
ask Causes mailx to prompt you for the subject of each mes-
sage you send. If you respond with a newline (carriage
return), no subject field is set. This option is
enabled by default.
askcc
Causes you to be prompted for the addresses of people to
receive copies of the message. Responding with a new-
line indicates your satisfaction with the current list.
asksub
Prompts for subject if it is not specified on the com-
mand line with the -s flag. Identical to ask.
autoprint
Causes the delete subcommand to behave like dp. Thus,
after deleting a message, the next one is typed automat-
ically.
bang
Enables the special-case treatment of ! (exclamation
points) in escape command lines as in vi. The default
is nobang.
debug
Causes mailx to display debugging information. mailx
does not send mail while in debug mode. Same as speci-
fying -d on the command line.
dot Causes mailx to interpret a period alone on a line as
the terminator of a message you are sending.
header
Enables printing of the header summary when entering
mailx. This option is enabled by default.
hold
Holds messages in the system mailbox by default.
ignore
Causes Interrupt signals from your terminal to be
ignored and echoed as @'s.
ignoreeof
Makes mailx refuse to accept End-of-File key sequence as
the end of a message or as the quit subcommand. Related
to the dot subcommand.
keep
Truncates the mailbox to zero length when it is empty,
instead of removing it. This option is disabled by
default.
keepsave
Keeps messages that have been saved in other files in
the mailbox, instead of deleting them. The default is
nokeepsave.
metoo
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.
nosave
Prevents mailx from copying the partial letter to the
file dead.letter in your home directory when a message
is terminated with two Interrupt key sequences.
outfolder
Causes the files used to record outgoing messages to be
located in the directory specified by the folder option
unless the pathname is absolute. The default is noout-
folder. (See the folder option and the Save, Copy, fol-
lowup, and Followup subcommands.)
page
Inserts a formfeed after each message sent through the
pipe when used with the pipe command. The default is
nopage.
quiet
Suppresses the printing of the program banner when mailx
starts. (The banner is the line that shows the name of
the mail program.)
Replyall
Reverses the sense of the reply and Reply mailbox sub-
commands.
save
Enables saving of messages in dead.letter on interrupt
or delivery error. (See DEAD= for a description of this
file. This option is enabled by default.)
sendwait
Waits for the background mailer to finish before return-
ing. The default is nosendwait.
showto
Prints the recipient's name instead of the author's name
when displaying the header summary and the message is
from the user.
verbose
Runs mailx in verbose mode; the actual delivery of mes-
sages is displayed on the user's terminal. Same as
using the -v flag 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.
cmd=shell_command
Sets the default command for the pipe subcommand. There
is no default value.
crt=number
Causes the paging program to automatically be invoked
for messages that exceed number lines.
DEAD=file
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.
EDITOR=pathname
Defines the text editor invoked by the ~e and edit sub-
commands. The absolute pathname must be given. The
default editor is /usr/bin/ex.
escape=character
Defines a character to use in the place of ~ (tilde) to
denote escapes.
folder=pathname
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.
indentprefix=string
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.
LISTER=shell_command
Specifies the command (and arguments) to use when list-
ing the contents of the folder directory. The default
is ls.
MBOX=file
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.
PAGER=pathname
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.
prompt=string
Sets the command mode prompt to string. The default is
?.
record=pathname
Specifies the pathname of the file (relative to $HOME)
used to record all outgoing mail. A copy of all the
messages you send out will be saved in this file.
Review this file periodically and delete all unnecessary
messages.
The mailx subcommands do not create directories, so any
directories 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.
screen=number
Controls how many lines of the message list are
displayed at a time. You can set this option to show a
certain number of lines on the screen. Each message in
your mailbox 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.
SHELL=pathname
Specifies the pathname of the shell to use in the ! and
~! subcommands. If this option is not defined, your
default shell is used.
sign=string
Specifies the variable inserted into the text of a mes-
sage when the ~a (autograph) subcommand is given. (See
also the ~i tilde escape.) There is no default value.
Sign=string
Specifies the variable inserted into the text of a mes-
sage when the ~A subcommand is given. (See also the ~i
tilde escape.) There is no default value.
toplines=number
Specifies the number of lines of a message to be
displayed with the top subcommand; normally, the first
five lines are displayed.
VISUAL=pathname
Specifies the pathname of the text editor to use in the
visual and ~v subcommands. The default pathname is
/usr/bin/vi.
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 pro-
cess, 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 address mail.
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 dis-
tribution list (more than one address).
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, and Bcc.
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.
EXAMPLES
1. 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 [Appended] 32/947
In this example, message 1 was added to the end of the
folder procedures. 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
2. To look at the contents of a specific mail folder,
enter the following at the command-line prompt:
mailx -f +dept
In this example, a listing of the messages in the dept
folder is displayed.
3. To prevent the Date, From, and To headers from being
displayed when a message is read with the type or the
print subcommand, enter the following statement in your
$HOME/.mailrc file:
ignore date from to
When a message is displayed using 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 subcom-
mands to display the message.
4. To keep a record of messages you send to others, enter
the following statement in your $HOME/.mailrc file:
set record=letters/mailout
5. 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 command 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.
FILES
/var/spool/mail/*
User mailbox files.
$HOME/mbox Holds saved mail.
$HOME/.mailrc
File containing mailx subcommands to customize
mailx for a specific user.
/usr/share/lib/Mail.rc
File containing mailx subcommands to change mailx
for all users on the system.
RELATED INFORMATION
Commands: mail(1)/binmail(1), fmt(1), pg(1), sendmail(8).
Acknowledgement and Disclaimer