NAME
mailx - interactive message processing system

SYNOPSIS
mailx [ options ] [ name... ]

DESCRIPTION
The command mailx provides a comfortable, flexible environment for sending and receiving messages electronically. When reading mail, \f4mailx\f1 provides commands to facilitate saving, deleting, and responding to messages. When sending mail, \f4mailx\f1 allows editing, reviewing and other modification of the message as it is entered.

Many of the remote features of mailx work only if the Basic Networking Utilities are installed on your system.

Incoming mail is stored in a standard file for each user, called the \f4mailbox\f1 for that user. When \f4mailx\f1 is called to read messages, the \f4mailbox\f1 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 \f4mbox\f1 and is normally located in the user's HOME directory [see (ENVIRONMENT VARIABLES) 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 option of the \f4mailx\f1 command. Messages in the secondary file can then be read or otherwise processed using the same COMMANDS as in the primary \f4mailbox\f1. This gives rise within these pages to the notion of a current \f4mailbox\f1.

On the command line, options start with a dash (-) and any other arguments are taken to be destinations (recipients). If no recipients are specified, \f4mailx\f1 attempts to read messages from the \f4mailbox\f1. Command-line options are:

    -d  Turn on debugging output.

    -e  Test for presence of mail. mailx prints nothing and exits with a successful return code if there is mail to read.

    -f [\f2filename\f1]
        Read messages from \f2filename\f1 instead of \f4mailbox\f1. If no \f2filename\f1 is specified, the \f4mbox\f1 is used.

    -F  Record the message in a file named after the first recipient. Overrides the variable, if set (see ENVIRONMENT VARIABLES).

    -h \f2number\f1
        The number of network ``hops'' made so far. This is provided for network software to avoid infinite delivery loops. This option and its argument is passed to the delivery program.

    -H  Print header summary only.

    -i  Ignore interrupts. See also (ENVIRONMENT VARIABLES).

    -I  Include the newsgroup and article-id header lines when printing mail messages. This option requires the -f option to be specified.

    -n  Do not initialize from the system default mailx.rc file.

    -N  Do not print initial header summary.

    -r address
        Use address as the return address when invoking the delivery program. All tilde commands are disabled. This option and its argument is passed to the delivery program.

    -s subject
        Set the Subject header field to subject.

    -T file
        Message-id and article-id header lines are recorded in file after the message is read. This option will also set the -I option.

    -u user
        Read user's \f4mailbox\f1. This is only effective if user's \f4mailbox\f1 is not read protected.

    -U  Convert uucp style addresses to internet standards. Overrides the environment variable.

    -V  Print the \f4mailx\f1 version number and exit.

When reading mail, \f4mailx\f1 is in command mode. A header summary of the first several messages is displayed, followed by a prompt indicating \f4mailx\f1 can accept regular commands (see COMMANDS below). When sending mail, \f4mailx\f1 is in input mode. If no subject is specified on the command line, a prompt for the subject is printed. (A subject longer than 1024 characters causes \f4mailx\f1 to print the message mail: ERROR signal 10; the mail will not be delivered.) As the message is typed, \f4mailx\f1 reads the message and store it in a temporary file. Commands may 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 \f4mailx\f1 is governed by a set of environment variables. These are flags and valued parameters which are set and cleared via the set and unset commands. See ENVIRONMENT VARIABLES below for a summary of these parameters.

Recipients listed on the command line may be of three types: login names, shell commands, or alias groups. Login names may 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 the standard input, such as lp(1) 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

    [ 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 (\f2msglist\f1) to operate on. The default for msglist is the current message. A \f2msglist\f1 is a list of message identifiers separated by spaces, which may 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. File names, where expected, are expanded via the normal shell conventions [see sh(1)]. Special characters are recognized by certain commands and are documented with the commands below.

At start-up time, \f4mailx\f1 tries to execute commands from the optional system-wide file (/etc/mail/mailx.rc) to initialize certain parameters, then from a private start-up file ($HOME/.mailrc) for 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 \f4.mailrc\f1 file is optional, and must be constructed locally.

  COMMANDS
The following is a complete list of \f4mailx\f1 commands:

Escape to the shell. See (ENVIRONMENT VARIABLES). Null command (comment). This may be useful in \f4.mailrc\f1 files. Print the current message number. Prints a summary of commands. Declare an alias for the given names. The names are substituted when \f2alias\f1 is used as a recipient. Useful in the \f4.mailrc\f1 file. Declares a list of alternate names for your login. When responding to a message, these names are removed from the list of recipients for the response. With no arguments, alternates prints the current list of alternate names. See also (ENVIRONMENT VARIABLES). Change directory. If \f2directory\f1 is not specified, $HOME is used. Copy messages to the file without marking the messages as saved. Otherwise equivalent to the save command. Save the specified messages in a file whose name is derived from the author of the message to be saved, without marking the messages as saved. Otherwise equivalent to the Save command. Delete messages from the \f4mailbox\f1. If is set, the next message after the last one deleted is printed (see ENVIRONMENT VARIABLES). Suppresses printing of the specified header fields when displaying messages on the screen. Examples of header fields to ignore are status and cc. The fields are included when the message is saved. The Print and Type commands override this command. If no header is specified, the current list of header fields being ignored will be printed. See also the undiscard and unignore commands. Delete the specified messages from the \f4mailbox\f1 and print the next message after the last one deleted. Roughly equivalent to a delete command followed by a print command. Echo the given strings [like echo(1)]. Edit the given messages. The messages are placed in a temporary file and the variable is used to get the name of the editor (see ENVIRONMENT VARIABLES). Default editor is ed(1). Exit from \f4mailx\f1, without changing the \f4mailbox\f1. No messages are saved in the \f4mbox\f1 (see also quit). Quit from the current file of messages and read in the specified file. Several special characters are recognized when used as file names, with the following substitutions:

    %   the current \f4mailbox\f1.

    %user
        the \f4mailbox\f1 for user.

    #   the previous file.

    &   the current \f4mbox\f1.
    Default file is the current \f4mailbox\f1.
Print the names of the files in the directory set by the variable (see ENVIRONMENT VARIABLES). Respond to a message, recording the response in a file whose name is derived from the author of the message. Overrides the variable, if set. See also the Followup, Save, and Copy commands and (ENVIRONMENT VARIABLES). Respond to the first message in the \f2msglist\f1, sending the message to the author of each message in the \f2msglist\f1. 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 (ENVIRONMENT VARIABLES). Prints the header summary for the specified messages. Declare an alias for the given names. The names are substituted when \f2alias\f1 is used as a recipient. Useful in the \f4.mailrc\f1 file. Prints the page of headers which includes the message specified. The variable sets the number of headers per page (see ENVIRONMENT VARIABLES). See also the z command. Prints a summary of commands. Holds the specified messages in the \f4mailbox\f1. Conditional execution, where s executes following \f2mail-command\f1s, up to an else or endif, if the program is in send mode, and r causes the \f2mail-command\f1s to be executed only in receive mode. Useful in the \f4.mailrc\f1 file. Suppresses 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 Print and Type commands override this command. If no header is specified, the current list of header fields being ignored will be printed. See also the undiscard and unignore commands. Prints all commands available. No explanation is given. Mail a message to the specified users. Mail a message to the specified user and record a copy of it in a file named after that user. Arrange for the given messages to end up in the standard \f4mbox\f1 save file when \f4mailx\f1 terminates normally. See (ENVIRONMENT VARIABLES) for a description of this file. See also the exit and quit commands. Go to next message matching \f2message. A \f2msglist\f1 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 \f2msglist\f1s above for a description of possible message specifications. Pipe the message through the given \f2shell-command\f1. 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 variable. If the variable is set, a form feed character is inserted after each message (see ENVIRONMENT VARIABLES). Preserve the specified messages in the \f4mailbox\f1. Print the specified messages on the screen, including all header fields. Overrides suppression of fields by the ignore command. Print the specified messages. If is set, the messages longer than the number of lines specified by the variable are paged through the command specified by the variable. The default command is pg(1) (see ENVIRONMENT VARIABLES). Exit from \f4mailx\f1, storing messages that were read in \f4mbox\f1 and unread messages in the \f4mailbox\f1. Messages that have been explicitly saved in a file are deleted. Send a response to the author of each message in the \f2msglist\f1. The subject line is taken from the first message. If is set to a file name, the response is saved at the end of that file (see ENVIRONMENT VARIABLES). Reply to the specified message, including all other recipients of the message. If is set to a file name, the response is saved at the end of that file (see ENVIRONMENT VARIABLES). 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 (ENVIRONMENT VARIABLES). Save the specified messages in the given file. The file is created if it does not exist. THe file defaults to \f4mbox\f1. The message is deleted from the \f4mailbox\f1 when \f4mailx\f1 terminates unless is set (see also ENVIRONMENT VARIABLES and the exit and quit commands). Define a variable called \f2name\f1. The variable may be given a null, string, or numeric value. Set by itself prints all defined variables and their values. See ENVIRONMENT VARIABLES for detailed descriptions of the \f4mailx\f1 variables. Invoke an interactive shell [see also (ENVIRONMENT VARIABLES)]. Print the size in characters of the specified messages. Read commands from the given file and return to command mode. Print the top few lines of the specified messages. If the variable is set, it is taken as the number of lines to print (see ENVIRONMENT VARIABLES). The default is 5. Touch the specified messages. If any message in \f2msglist\f1 is not specifically saved in a file, it is placed in the \f4mbox\f1, or the file specified in the environment variable, upon normal termination. See exit and quit. Print the specified messages on the screen, including all header fields. Overrides suppression of fields by the ignore command. Print the specified messages. If is set, the messages longer than the number of lines specified by the variable are paged through the command specified by the variable. The default command is pg(1) (see ENVIRONMENT VARIABLES). Restore the specified deleted messages. Will only restore messages deleted in the current mail session. If is set, the last message of those restored is printed (see ENVIRONMENT VARIABLES). Remove the specified header fields from the list being ignored. Causes the specified variables to be erased. If the variable was imported from the execution environment (i.e., a shell variable) then it cannot be erased. Prints the current version. Edit the given messages with a screen editor. The messages are placed in a temporary file and the variable is used to get the name of the editor (see ENVIRONMENT VARIABLES). Write the given messages on the specified file, minus the header and trailing blank line. Otherwise equivalent to the save command. Exit from \f4mailx\f1, without changing the \f4mailbox\f1. No messages are saved in the \f4mbox\f1 (see also quit). Scroll the header display forward or backward one screen-full. The number of headers displayed is set by the variable (see ENVIRONMENT VARIABLES).

  TILDE ESCAPES
The following commands may be entered only from input mode, by beginning a line with the tilde escape character (~). See (ENVIRONMENT VARIABLES) for changing this special character.

Escape to the shell. Simulate end of file (terminate message input). Perform the command-level request. Valid only when sending a message while reading mail. Print a summary of tilde escapes. Insert the autograph string into the message (see ENVIRONMENT VARIABLES). Insert the autograph string into the message (see ENVIRONMENT VARIABLES). Add the \f2name\f1s to the blind carbon copy (Bcc) list. Add the \f2name\f1s to the carbon copy (Cc) list. Read in the \f4dead.letter\f1 file. See (ENVIRONMENT VARIABLES) for a description of this file. Invoke the editor on the partial message. See also (ENVIRONMENT VARIABLES). Forward the specified messages. The messages are inserted into the message without alteration. Prompt for Subject line and To, Cc, and Bcc lists. If the field is displayed with an initial value, it may be edited as if you had just typed it. Insert the value of the named variable into the text of the message. For example, ~A is equivalent to '~i\f4Sign.' Environment variables set and exported in the shell are also accessible by ~i. Insert the specified messages into the letter, shifting the new text to the right one tab stop. Valid only when sending a message while reading mail. Print the message being entered. Quit from input mode by simulating an interrupt. If the body of the message is not null, the partial message is saved in \f4dead.letter\f1. See (ENVIRONMENT VARIABLES) for a description of this file. 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. Set the subject line to \f2string\f1. Add the given \f2name\f1s to the To list. Invoke a preferred screen editor on the partial message. See also (ENVIRONMENT VARIABLES). Write the message into the given file, without the header. Exit as with ~q except the message is not saved in \f4dead.letter\f1. Pipe the body of the message through the given \f2shell-command\f1. If the \f2shell-command\f1 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 \f4mailx\f1. The user's base of operations. The name of the start-up file. Default is $HOME/.mailrc.

The following variables are internal \f4mailx\f1 variables. They may be imported from the execution environment or set via the set command at any time. The unset command may be used to erase variables.

All network names whose last component (login name) match are treated as identical. This causes the \f2msglist\f1 message specifications to behave similarly. Default is noallnet. See also the alternates command and the variable. Upon termination, append messages to the end of the \f4mbox\f1 file instead of prepending them. Default is noappend. Prompt for the Cc list after the Subject is entered. Default is noaskcc. Prompt for the Bcc list after the Subject is entered. Default is noaskbcc. Prompt for subject if it is not specified on the command line with the -s option. Enabled by default. Enable automatic printing of messages after delete and undelete commands. Default is noautoprint. Enable the special-casing of exclamation points (!) in shell escape command lines as in vi(1). Default is nobang. Set the default command for the pipe command. No default value. Convert uucp addresses to the specified address style. The only valid conversion now is internet, which uses domain-style addressing. Conversion is disabled by default. See also the -U command-line option. Pipe messages having more than number lines through the command specified by the value of the variable [pg(1) by default]. Disabled by default. The name of the file in which to save partial letters in case of untimely interrupt. Default is $HOME/dead.letter. Enable verbose diagnostics for debugging. Messages are not delivered. Default is nodebug. Take a period on a line by itself during input from a terminal as end-of-file. Default is nodot. The command to run when the edit or ~e command is used. Default is ed(1). Substitute c for the ~ escape character. Takes effect with next message sent. 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 \f2directory\f1 does not start with a slash (/), $HOME is prepended to it. In order to use the plus (+) construct on a \f4mailx\f1 command line, must be an exported sh environment variable. There is no default for the variable. See also below. Enable printing of the header summary when entering \f4mailx\f1. Enabled by default. Preserve all messages that are read in the \f4mailbox\f1 instead of putting them in the standard \f4mbox\f1 save file. Default is nohold. Ignore interrupts while entering messages. Handy for noisy dial-up lines. Default is noignore. Ignore end-of-file during message input. Input must be terminated by a period (.) on a line by itself or by the ~. command. Default is noignoreeof. See also above. When the \f4mailbox\f1 is empty, truncate it to zero length instead of removing it. Disabled by default. Keep messages that have been saved in other files in the \f4mailbox\f1 instead of deleting them. Default is nokeepsave. The name of the file to save messages which have been read. The xit command overrides this function, as does saving the message explicitly in another file. Default is $HOME/mbox. If your login appears as a recipient, do not delete it from the list. Default is nometoo. The command (and options) to use when listing the contents of the directory. The default is ls(1). 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 (i.e., one hop away). Causes the files used to record outgoing messages to be located in the directory specified by the variable unless the path name is absolute. Default is nooutfolder. See above and the Save, Copy, followup, and Followup commands. Used with the pipe command to insert a form feed after each message sent through the pipe. Default is nopage. The command to use as a filter for paginating output. This can also be used to specify the options to be used. Default is pg(1). Set the command mode prompt to \f2string\f1. Default is ``? ''. Refrain from printing the opening message and version when entering \f4mailx\f1. Default is noquiet. Record all outgoing mail in \f2filename\f1. Disabled by default. See also above. If you have the and variables set but the variable not set, messages are saved in +\f2filename\f1 instead of \f2filename\f1. Enable saving of messages in \f4dead.letter\f1 on interrupt or delivery error. See for a description of this file. Enabled by default. Sets the number of lines in a screen-full of headers for the headers command. It must be a positive number. Alternate command for delivering messages. Default is /usr/bin/rmail. Wait for background mailer to finish before returning. Default is nosendwait. The name of a preferred command interpreter. Default is sh(1). When displaying the header summary and the message is from you, print the recipient's name instead of the author's name. The variable inserted into the text of a message when the ~a (autograph) command is given. No default [see also ~i (TILDE ESCAPES)]. The variable inserted into the text of a message when the ~A command is given. No default [see also ~i (TILDE ESCAPES)]. The number of lines of header to print with the top command. Default is 5. The name of a preferred screen editor. Default is vi(1).

FILES
$HOME/.mailrc | personal start-up file
$HOME/mbox | secondary storage file
/var/mail/* | post office directory
/usr/share/lib/mailx/mailx.help* | help message files
/etc/mail/mailx.rc | optional global start-up file
/tmp/R[emqsx]* | temporary files

SEE ALSO
ls(1), mail(1), pg(1).

NOTES
The -h and -r options can be used only if \f4mailx\f1 is using a delivery program other than /usr/bin/rmail.

Where \f2shell-command\f1 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 \f4mailx\f1. The new standards need some time to settle down.

Attempts to send a message having a line consisting only of a ``.'' are treated as the end of the message by mail(1) (the standard mail delivery program).