mailx(1) CLIX mailx(1)
NAME
mailx - Runs and interactive mail system
SYNOPSIS
mailx [flag ... ] [name ... ] The mailx command provides a flexible
environment for sending and receiving messages electronically.
FLAGS
-e Tests for presence of mail. The mailx command displays
nothing and exits with a successful return code if there
is mail to read.
-f [filename] Reads messages from filename instead of mailbox. If no
filename is specified, the mailbox is used.
-F Records the message in a file named after the first
recipient. Overrides the RECORD variable, if set (see
ENVIRONMENT VARIABLES).
-h number The number of network ``hops'' made so far. This is
provided for network software to avoid infinite delivery
loops. (See addsopt under ENVIRONMENT VARIABLES)
-H Display header summary only.
-i Causes interrupts to be ignored. See also ignore
(ENVIRONMENT VARIABLES).
-n Prevents initialization from system default mailx.rc file.
-N Prevents displaying of the initial header summary.
-r address Passes address to network delivery software. All tilde
(~) commands are disabled. (See addsopt ENVIRONMENT
VARIABLES heading.)
-s subject Sets the Subject header field to subject.
-u user Reads user's mailbox. This is only effective if the
user's mailbox is not read protected.
-U Converts uucp style addresses to internet standards.
Overrides the CONV environment variable. (See addsopt
under ENVIRONMENT VARIABLES heading.)
DESCRIPTION
The mailx command provides a comfortable, flexible environment for sending
2/94 - Intergraph Corporation 1
mailx(1) CLIX mailx(1)
and receiving messages electronically. When reading mail, mailx provides
commands to facilitate saving, deleting, and responding to messages. When
sending mail, mailx allows editing, reviewing, and other modification of
the message as it is entered.
Many of the remote features of mailx will only work if the Basic
Networking Utilities are installed on your system.
Incoming mail is stored in a standard file for each user, called the
mailbox for that user. When mailx is called to read messages, the mailbox
is the default place to find them. As messages are read, 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 normally located in the user's HOME directory
(see MBOX under ENVIRONMENT VARIABLES heading for a description of this
file). Messages can be saved in other secondary files named by the user.
Messages remain in a secondary file until forcibly removed.
The user can access a secondary file by using the -f flag of the mailx
command. Messages in the secondary file can then be read or otherwise
processed using the same COMMANDS as in the primary mailbox. This gives
rise within these pages to the notion of a current mailbox.
When reading mail, mailx is in command mode. A header summary of the
first several messages is displayed, followed by a prompt indicating mailx
can accept regular commands (see COMMANDS below). When sending mail,
mailx is in input mode. If no subject is specified on the command line, a
prompt for the subject is displayed. (A subject longer than 1024
characters will cause mailx to dump core.) As the message is typed, mailx
will read the message and store 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 TILDE ESCAPES for
a summary of these commands.
At any time, the behavior of mailx is governed by a set of ENVIRONMENT
VARIABLES. These are options and valued parameters that are set and
cleared with the set and unset commands. See ENVIRONMENT VARIABLES below
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 mail is found to be undeliverable,
an attempt is made to return it to the sender's mailbox. If the recipient
name begins with a pipe symbol (|), the rest of the name is taken to be a
shell command to pipe the message through. This provides an automatic
interface with any program that reads stdin, such as lp, for recording
outgoing mail on paper. Alias groups are set by the alias command (see
COMMANDS below) and are lists of recipients of any type.
Regular commands are of the form
2 Intergraph Corporation - 2/94
mailx(1) CLIX mailx(1)
[command] [msglist] [arguments]
If no command is specified in command mode, print is assumed. In input
mode, commands are recognized by the escape character, and lines not
treated as commands are taken as input for the message.
Each message is assigned a sequential number, and there is at any time the
notion of a current message, marked by a right angle bracket (>) in the
header summary. Many commands take an optional list of messages (msglist)
to operate on. The default for msglist is the current message. A msglist
is a list of message identifiers separated by spaces, which can include:
n Message number n.
. The current message.
^ The first undeleted message.
$ The last message.
* All messages.
n-m An inclusive range of message numbers.
user All messages from user.
/string All messages with string in the subject line (case ignored).
:c All messages of type c, where c is one of:
d Deleted messages
n New messages
o Old messages
r Read messages
u 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. Filenames, where expected, are expanded with the normal
shell conventions (see sh). Special characters are recognized by certain
commands and are documented with the commands below.
At start-up time, mailx tries to execute commands from the optional
system-wide file (/usr/lib/mailx/mailx.rc) to initialize certain
parameters, then from a private start-up file ($HOME/.mailrc) for
2/94 - Intergraph Corporation 3
mailx(1) CLIX mailx(1)
personalized variables. With the exceptions noted below, regular commands
are legal inside start-up files. The most common use of a start-up file
is to set up initial display options and alias lists. The following
commands are not legal in the start-up file: !, Copy, edit, followup,
Followup, hold, mail, preserve, reply, Reply, shell, and visual. An error
in the start-up file causes the remaining lines in the file to be ignored.
The .mailrc file is optional, and must be constructed locally.
COMMANDS
The following is a complete list of mailx commands:
!shell-command
Escape to the shell. See SHELL (ENVIRONMENT VARIABLES).
# comment
Null command (comment). This can be useful in .mailrc files.
= Display the current message number.
? Display a summary of commands.
alias alias name ...
group alias name ...
Declare an alias for the given names. The names will be
substituted when alias is used as a recipient. Useful in the
.mailrc file.
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, alternates displays the
current list of alternate names. See also allnet (ENVIRONMENT
VARIABLES).
cd [directory]
chdir [directory]
Change directory. If directory is not specified, $HOME is used.
copy [filename]
copy [msglist] filename
Copy messages to the file without marking the messages as saved.
Otherwise equivalent to the save command.
Copy [msglist]
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 [msglist]
Delete messages from the mailbox. If autoprint is set, the next
4 Intergraph Corporation - 2/94
mailx(1) CLIX mailx(1)
message after the last one deleted is displayed (see ENVIRONMENT
VARIABLES).
discard [header-field ... ]
ignore [header-field ... ]
Suppress displaying 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 Print and Type commands override this command.
dp [msglist]
dt [msglist]
Delete the specified messages from the mailbox and displays 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).
edit [msglist]
Edit the given messages. The messages are placed in a temporary
file and the EDITOR variable is used to get the name of the editor
(see ENVIRONMENT VARIABLES). The default editor is ed.
xit
exit Exit from mailx, without changing the mailbox. No messages are
saved in the mailbox (see also quit).
file [filename]
folder [filename]
Quit from the current file of messages and read in the specified
file. Several special characters are recognized when used as
filenames, with the following substitutions:
% The current mailbox.
%user The mailbox for user.
# The previous file.
& The current mbox.
The default file is the current mailbox.
folders
Display the names of the files in the directory set by the FOLDER
variable (see ENVIRONMENT 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
2/94 - Intergraph Corporation 5
mailx(1) CLIX mailx(1)
variable, if set. See also the Followup, Save, and Copy commands
and outfolder (ENVIRONMENT VARIABLES).
Followup [msglist]
Respond to the first message in the msglist, sending the message to
the author of each message in the msglist. 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 outfolder
(ENVIRONMENT VARIABLES).
from [msglist]
Display the header summary for the specified messages.
group alias name ...
alias alias name ...
Declare an alias for the given names. The names will be
substituted when alias is used as a recipient. Useful in the
.mailrc file.
headers [message]
Display the page of headers that includes the message specified.
The SCREEN variable sets the number of headers per page (see
ENVIRONMENT VARIABLES). See also the z command.
help Displays a summary of commands.
hold [msglist]
preserve [msglist]
Hold the specified messages in the mailbox.
if s|r
mail-commands
else
mail-commands
endif Conditional execution, where s will execute following mail-
commands, up to an else or endif, if the program is in send mode,
and r causes the mail-commands to be executed only in receive mode.
Useful in the .mailrc file.
ignore header-field ...
discard header-field ...
Suppress displaying 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 Print and Type commands override this command.
list Display all commands available. No explanation is given.
mail name ...
Mail a message to the specified users.
6 Intergraph Corporation - 2/94
mailx(1) CLIX mailx(1)
Mail name
Mails a message to the specified user and record a copy of it in a
file named after that user.
mbox [msglist]
Arrange for the given messages to end up in the standard mailbox
save file when mailx terminates normally. See MBOX (ENVIRONMENT
VARIABLES) for a description of this file. See also the exit and
quit commands.
next [message]
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 taken as a command in the
absence of a real command. See the discussion of msglists above
for a description of possible message specifications.
pipe [msglist] [shell-command]
[msglist] [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 formfeed character is
inserted after each message (see ENVIRONMENT VARIABLES).
preserve [msglist]
hold [msglist]
Preserve or hold the specified messages in the mailbox.
Print [msglist]
Type [msglist]
Display the specified messages on the screen, including all header
fields. Overrides suppression of fields by the ignore command.
print [msglist]
type [msglist]
Display 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 (see ENVIRONMENT VARIABLES).
quit Exit from mailx, storing messages that were read in mailbox and
unread messages in the mailbox. Messages that have been explicitly
saved in a file are deleted.
Reply [msglist]
Respond [msglist]
Send a response to the author of each message in the msglist. The
subject line is taken from the first message. If record is set to
a filename, the response is saved at the end of that file (see
2/94 - Intergraph Corporation 7
mailx(1) CLIX mailx(1)
ENVIRONMENT VARIABLES).
reply [message]
respond [message]
Reply to the specified message, including all other recipients of
the message. If record is set to a filename, the response is saved
at the end of that file (see ENVIRONMENT VARIABLES).
Save [msglist]
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
(ENVIRONMENT VARIABLES).
save [filename]
save [msglist] filename
Save the specified messages in the given file. The file is created
if it does not exist. The message is deleted from the mailbox when
lx terminates unless keepsave is set (see also ENVIRONMENT
VARIABLES and the exit and quit commands).
set
set name
set name=string
set name=number
Define a variable called name. The variable can be given a null,
string, or numeric value. The set command by itself displays all
defined variables and their values. See ENVIRONMENT VARIABLES for
detailed descriptions of the mailx variables.
shell Invoke an interactive shell (see also SHELL (ENVIRONMENT
VARIABLES)).
size [msglist]
Display the size in characters of the specified messages.
source filename
Read commands from the given file and returns to command mode.
top [msglist]
Display the top few lines of the specified messages. If the
toplines variable is set, it is taken as the number of lines to
display (see ENVIRONMENT VARIABLES). The default is 5.
touch [msglist]
Touch the specified messages. If any message in msglist is not
specifically saved in a file, it will be placed in the mailbox, or
the file specified in the MBOX environment variable, upon normal
termination. See exit and quit.
8 Intergraph Corporation - 2/94
mailx(1) CLIX mailx(1)
Type [msglist]
Print [msglist]
Display the specified messages on the screen, including all header
fields. Overrides suppression of fields by the ignore command.
type [msglist]
print [msglist]
Display 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 (see ENVIRONMENT VARIABLES).
undelete [msglist]
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 displayed (see ENVIRONMENT VARIABLES).
unset name ...
Erase the specified variables. If the variable was imported from
the execution environment (in other words, a shell variable) then
it cannot be erased.
version
Display the current version and release date.
visual [msglist]
Edit the given messages with a screen editor. The messages are
placed in a temporary file and the VISUAL variable is used to get
the name of the editor (see ENVIRONMENT VARIABLES).
write [msglist] filename
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 mailbox (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
ENVIRONMENT VARIABLES).
TILDE ESCAPES
The following commands can be entered only from input mode, by beginning a
line with the tilde escape character (~). See escape (under the
ENVIRONMENT VARIABLES heading) to change this special character.
~! shell-command
Escape to the shell.
2/94 - Intergraph Corporation 9
mailx(1) CLIX mailx(1)
~. 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.
~? Display a summary of tilde escapes.
~A Insert the autograph string Sign into the message (see ENVIRONMENT
VARIABLES).
~a Insert the autograph string sign into the message (see ENVIRONMENT
VARIABLES).
~b name ...
Add the names to the blind carbon copy (Bcc) list.
~c name ...
Add the names to the carbon copy (Cc) list.
~d Read in the dead.letter file. See DEAD (under the ENVIRONMENT
VARIABLES heading) for a description of this file.
~e Invoke the editor on the partial message. (See also EDITOR
ENVIRONMENT VARIABLES.)
~f [msglist]
Forward the specified messages. The messages are inserted into the
message without alteration.
~h 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.
~i string
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 [msglist]
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.
~p Display the message being entered.
~q Quit 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 under ENVIRONMENT VARIABLES heading for a description of
this file.)
10 Intergraph Corporation - 2/94
mailx(1) CLIX mailx(1)
~r filename
~~< filename
~~< !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 stdout inserted into
the message.
~s string ...
Set the subject line to string.
~t name ...
Adds the given s to the To list.
~v Invoke a preferred screen editor on the partial message. See also
VISUAL (under the ENVIRONMENT VARIABLES heading).
~w filename
Write the partial message onto 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.
ENVIRONMENT VARIABLES
The following are environment variables taken from the execution
environment and are not alterable within mailx.
HOME=directory
The user's base of operations.
MAILRC=filename
The name of the start-up file. Default is $HOME/.mailrc.
TMPDIR(eqdirectory
The user's temporary base of operations.
The following variables are internal mailx variables. They can be
imported from the execution environment or set with the set command at any
time. The unset command can be used to erase variables.
addsopt
Enabled by default. If /bin/mail is not being used as the
deliverer, noaddsop should be specified. (See CAUTIONS below)
allnet All network names whose last component (login name) match are
treated as identical. This causes the msglist message
2/94 - Intergraph Corporation 11
mailx(1) CLIX mailx(1)
specifications to behave similarly. Default is noallnet. See also
the alternates command and the metoo variable.
append Upon termination, appends messages to the end of the mailbox file
instead of prepending them. Default is noappend
askcc Prompts for the Cc list after message is entered. Default is
noaskcc.
asksub Prompts for subject if it is not specified on the command line with
the -s flag. Enabled by default.
autoprint
Enable automatic displaying of messages after delete and undelete
commands. Default is noautoprint
bang Enable the special-casing of exclamation points (!) in shell escape
command lines as in vi. Default is nobang.
cmd=shell-command
Set the default command for the pipe command. No default value.
conv=conversion
Convert uucp addresses to the specified address style. The only
valid conversion now is internet, which requires a mail delivery
program conforming to the RFC822 standard for electronic mail
addressing. Conversion is disabled by default. See also sendmail
and the -U command line flag.
crt=number
Pipe messages having more than number lines through the command
specified by the value of the PAGER variable (pg by default).
Disabled by default.
DEAD=filename
The name of the file in which to save partial letters in case of
untimely interrupt. Default is $HOME/dead.letter.
debug Enable verbose diagnostics for debugging. Messages are not
delivered. Default is nodebug.
dot Take a period on a line by itself during input from a terminal as
end-of-file. Default is nodot.
EDITOR=shell-command
The command to run when the edit or ~e command is used. Default is
ed.
escape=c
Substitute c for the ~ escape character. Takes effect with next
message sent.
12 Intergraph Corporation - 2/94
mailx(1) CLIX mailx(1)
folder=directory
The directory for saving standard mail files. User-specified
filenames beginning with a plus (+) are expanded by preceding the
filename with this directory name to obtain the real filename. If
directory does not start with a slash (/), $HOME is prepended to
it. In order to use the plus (+) construct on a mailx command
line, folder must be an exported sh environment variable. There is
no default for the folder variable. See also outfolder below.
header Enable displaying 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. Default is nohold
ignore Ignore interrupts while entering messages. Handy for noisy dial-up
lines. Default is noignore.
ignoreeof
Ignore end-of-file during message input. Input must be terminated
by a dot (.) on a line by itself or by the ~. command. Default is
noignoreeof. See also dot above.
keep When the mailbox is empty, truncates it to zero length instead of
removing it. Disabled by default.
keepsave
Keep messages that have been saved in other files in the mailbox
instead of deleting them. Default is nokeepsave.
MBOX=filename
The name of the file in which to save messages that have been read.
The xit command overrides this function, as does saving the message
explicitly in another file. Default is $HOME/mbox.
meto If your login appears as a recipient, this variable ensures your
login is not deleted from the list. Default is nometoo.
LISTER=shell-command
The command (and flags) to use when listing the contents of the
folder directory. The default is ls.
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 (in other words, one hop away).
outfolder
Causes the files used to record outgoing messages to be located in
2/94 - Intergraph Corporation 13
mailx(1) CLIX mailx(1)
the directory specified by the folder variable unless the pathname
is absolute. Default is nooutfolder. See folder above and the
Save, Copy, followup, and Followup commands.
page Used with the pipe command to insert a formfeed after each message
sent through the pipe. Default is nopage.
PAGER=shell-command
The command to use as a filter for paginating output. This can
also be used to specify the flags to be used. Default is pg.
prompt=string
Set the command mode prompt to string. Default is ?.
quiet Cause mailx to refrain from displaying the opening message and
version. Default is noquiet.
record=filename
Record all outgoing mail in filename. Disabled by default. See
also outfolder above.
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
Set the number of lines in a screen-full of headers for the headers
command.
sendmail=shell-command
Alternate command for delivering messages. Default is /bin/rmail.
sendwait
Wait for background mailer to finish before returning. Default is
nosendwait.
SHELL=shell-command
The name of a preferred command interpreter. Default is sh.
showto When displaying the header summary and the message is from you,
this variable displays 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 (under the
TILDE ESCAPES heading)).
Sign=string
The variable inserted into the text of a message when the ~A
command is given. No default (see also ~i (under the TILDE ESCAPES
14 Intergraph Corporation - 2/94
mailx(1) CLIX mailx(1)
heading)).
toplines=number
The number of lines of header to display with the top command.
Default is 5.
VISUAL=shell-command
The name of a preferred screen editor. Default is vi.
FILES
$HOME/.mailrc Personal start-up file
$HOME/mbox Secondary storage file
/usr/mail/* Post office directory
/usr/lib/mailx/mailx.help* Help message files
/usr/lib/mailx/mailx.rc Optional global start-up file
/tmp[emqsx]* Temporary files
CAUTIONS
The -h, -r and -U flags can be used only if mailx is built with a delivery
program other than /bin/mail.
Where shell-command is shown as valid, arguments are not always allowed.
Experimentation is recommended.
Internal variables imported from the execution environment cannot be
unset.
The full internet addressing is not fully supported by mailx. The new
standards need some time to settle down.
Attempts to send a message having a line consisting only of a dot (.) are
treated as the end of the message by mail (the standard mail delivery
program).
DIAGNOSTICS
No mail for name
Mailbox is empty
cannot give -f and people to send to.
Cannot specify recipients if you are just reading a mailbox
interrupt
Interrupt signal was received
2/94 - Intergraph Corporation 15
mailx(1) CLIX mailx(1)
EXIT VALUES
The mailx command exits with a value of 0 if successful and 1 if not
successful.
RELATED INFORMATION
Commands: ls(1), mail(1), pg(1)
AT&T UNIX System V User's Guide
16 Intergraph Corporation - 2/94