mailx

read electronic mail 

Command


SYNOPSIS

mailx [-efHiNn] [-u user] [filename]

mailx [-FimnU] [-h number] [-p priority] [-r address] [-s subject] user ...


DESCRIPTION

mailx helps you read and send electronic mail messages. It has no built-in facilities for sending messages to other systems, but combined with other programs (a mail routing agent, and a transport agent), it can send messages to other systems.

The command line

mailx [options] user user user ...

sends a mail message to the given users. If you do not specify any users on the command line, mailx lets you read incoming mail interactively.

Options

mailx accepts the following options when you are reading messages:

-e 

checks to see if you have any messages waiting to be read. With this option, nothing is displayed. If you have waiting messages, mailx exits with a successful status return; otherwise, mailx exits with a failure return.

-f 

looks for messages in the file given by the optional filename on the command line instead of in your system mailbox. If you do not specify filename, mailx reads messages from the file specified by the MBOX variable; the default value for MBOX is ~/mbox.

-H 

displays only the header summary of a message.

-N 

does not display the header summary of messages.

-u user 

looks for messages in the system mailbox of the specified user. This only works if you have read permission on the user's system mailbox.

mailx accepts the following options only when you are sending messages:

-F 

records your message in a file with the same name as the first user specified on the command line. This option overrides the record variable, if it has been set. See the ENVIRONMENT VARIABLES section for more on the record variable.

-h number 

indicates how many hops a message has already made from one machine to another (in a network of machines). This option is not intended for most users; some network mail software uses the option to prevent infinite loops (the same message cycling through a sequence of machines without ever getting to its intended destination).

-p priority 

sets the priority of the mail message to be sent. priority can be low, normal, or high.

-r address 

passes the given address to network mail software. If this option is present, it disables all input mode commands.

-s subject 

uses the given subject string in the Subject heading line of the message. If the subject contains spaces or <tab> characters, the string should be enclosed in double quotes (" ") or apostrophes (' '). If you specify this option on the command line, mailx does not prompt you to enter a Subject line when you type in the text of the message.

-U 

converts the address from UUCP style to internet standards. This overrides the effect of the conv environment variable. See the ENVIRONMENT VARIABLES section for more information.

mailx accepts the following options when you are sending or reading messages:

-i 

ignores interrupts (for example, pressing BREAK or CTRL-C). Also see the description of the ignore environment variable in the section on ENVIRONMENT VARIABLES.

-m 

uses Microsoft Exchange compatibility mode. In this mode, the From line is:

From: username

and the Date line is

Date: DayofWeek, DayofMonth Mon Year HH:MM:SS timezoneoffset
-n 

does not initialize your mailx session from the system's ROOTDIR/etc/mailx.rc file. For more information about this file, see the Start-Up Files section.

General Overview

This section describes the default behavior of mailx. You can use mailx in many ways, and these are discussed later; however, you must first understand mailx's normal pattern of behavior.

The simplest command to send a message is

mailx address address address ...

where each address names someone who is to receive the message. The simplest kind of address is the login name of someone else who uses your machine.

You can also send messages as input to commands. To do this, use an address that consists of an or-bar (|) followed by a command line that invokes the appropriate command. Enclose this whole address in apostrophes. For example,

mailx robin '|cat >save'

mails a message to robin and also copies the message into a file called save.

After you type in the command to send a message, mailx asks you to enter the Subject of the message (this brief description of what the message is about can be up to 256 characters long). You can now type in the text of your message. Your message can consist of any number of lines, and may include blank lines. When you finish entering the message, type a line consisting only of a tilde (~), followed by a dot (.); then press ENTER. This tells mailx that the message is ready to be sent.

mailx puts the completed message into a file called the recipient's system mailbox. The message stays there until the recipient asks. At that point, the message is obtained from the system mailbox and displayed on the recipient's terminal. It is then saved in the recipient's personal mailbox. Since this is usually a file named mbox under the recipient's home directory, mbox represents the personal mailbox and mailbox represents the system mailbox.

The simplest way to read incoming messages is to type the command mailx (with no addresses on the command line). This starts an interactive session in which mailx lets you read your mail and perform other operations. For example, you can display new messages, delete old ones, reply to messages or forward them to someone else, and so on. When you are performing operations in this way, you are in command mode. When you are typing in the text of a message, you are in input mode.

A message consists of a sequence of header lines followed by the body of the message. The header lines tell who sent the message, the time and date that it was sent, its subject, and so on. mailx automatically creates header lines. Some of the common header lines are:

Cc: name name ... 

Stands for carbon copies. This indicates that copies of this message are to be sent to the specified recipients. The names of these recipients appear in the header lines of everyone receiving the message.

Bcc: name name ... 

Stands for blind carbon copies. This is similar to Cc: but the names of people receiving carbon copies do not appear in the header lines of the message. Recipients do not know that these people received a copy of the message.

Subject: text 

Gives the subject of the message.

To: name name ... 

Gives the names of people who were sent the message directly.

All messages are in one of the following states:

deleted 

You used a delete, dp, or dt command to delete the message, or you saved it using a Save or save command and the variable keepsave was not set. When mailx quits, it deletes messages in this state.

new 

The message is in the system mailbox and you have not yet read it or otherwise changed its state. When mailx quits, it retains messages in this state in your system mailbox.

preserved 

You used a preserve command on the message. When mailx quits, it retains messages in this state in their current locations.

read 

You used one of the following commands on the message:

~F        ~m        next      print     type
~f        copy      pipe      top       undelete
~M        mbox      Print     Type

or you used delete, dp, or dt on the preceding message and the autoprint environment variable was set. When mailx quits and you are in your system mailbox, it saves read messages in your personal mailbox unless the variable hold is set, in which case, it retains them in your system mailbox. If you are in your personal or a secondary mailbox when mailx quits, it retains read messages in their current location.

unread 

You have run more than one mailx session with the message in the system mailbox and you have not read it or otherwise changed its state. When mailx quits, it retains messages in this state in your system mailbox.

Command Mode Commands

The format of a command mode command is

[command][refs][arguments]

If no command is specified, p[rint] is assumed.

The refs argument indicates the messages to which you want to apply the command. mailx numbers incoming messages sequentially as they are received. The easiest way to refer to a message is to give its number. For example, the command

p 3

displays message number 3. At any point in a mailx session, there is one message that is considered the current message. Loosely speaking, this is the message you most recently used in a command (for example, the one you most recently read). If you omit the refs argument in a command that uses refs, the command works with the current message. You can also use special notations as the refs value, as in Table 1, Reference Notations.

Several refs may be specified for the same command, separated by spaces. For example,

p alice lewis

displays all messages from alice plus all messages from lewis.

Ref Meaning

n Message number n
n-m Messages n through m
. The current message
^ The first undeleted message
(or first deleted message for undelete)
$ The last message
* All messages
+ Next message
- Previous message
user All messages from the given user
/string All messages with string in the subject line
(the case of characters in string is ignored)
:d All deleted messages
:n All new messages
:o All old messages
:r All messages that have already been read
:u All unread messages

Table 1: Reference Notations

The arguments allowed at the end of a command mode command depend on the command itself. If a command allows a file name as an argument, the usual file name generation characters may be used in the file name. See sh.

The following list shows the commands recognized in command mode. In every command name, some characters are enclosed in square brackets. These characters are optional. For example, the p[rint] command may be given as print or p.

a[lias] [alias [name ...]] 

sets up an address alias, a single name which stands for another address or a group of addresses. If you issue a command to send mail to the given alias, the messages are actually sent to all of the addresses in the list. For example, you might issue the command

alias joe jsmith

From this point onward, you can address messages to joe and they are sent to jsmith. You may also set up an alias for several people, as in

alias choir soprano alto tenor bass

Once you have done this, you can use choir as the address, and the mail is sent to the other addresses (soprano, alto, tenor, and bass).

With only one argument, the alias command lists the value of that alias (for example, alias joe would display jsmith). Without any arguments, the alias command displays a list of the currently defined aliases.

Note:

Aliases which are entered interactively remain in effect only until the end of the current interactive session. To make an alias permanent, include the alias command in your start-up file (see Start-Up Files). See also group.

alt[ernates] name ... 

lists a set of alternate names for your own login name. This is useful for people who login under several different names. When you reply to a message, mailx usually sends your reply to the author of the message and all the recipients as well; however, it does not send the message to any of your alternate login names. In this way, you don't have to worry about sending mail to yourself.

Specifying alternates without names displays your list of currently defined alternate names.

cd directory 

makes directory your new working directory. If no directory is specified, cd goes to your HOME directory.

ch[dir] directory 

is the same as cd.

c[opy] [refs] [filename

copies the messages referenced by refs into the given file. The filename must be specified. If the file does not already exist, it is created.

If no refs are specified, the current message is saved. If no filename is specified, your mbox file is used.

This operation does not mark the message as saved; if it was previously unread, it is still regarded as an unread message. Thus the original message remains in your system mailbox. See also save.

C[opy] [refs

is similar to the copy command, except that the referenced messages are saved in a file the name of which is derived from the author of the first message referenced. The name of the file is the author's name, stripped of any network addressing. If the folder variable is set, the file is saved to the specified directory. The copied messages are not marked as saved. If no refs are specified, the current message is copied.

d[elete] [refs

deletes the specified messages. If no refs are specified, the current message is deleted. After a delete operation, the current message is set to the message after the last message deleted. Deleted messages are not thrown away until you end your session with the current mailbox (see quit, file). Until then, they can be undeleted (see undelete).

di[scard] [header ...] 

does not display the given header fields when displaying a message. For example,

discard References

tells mailx not to display the References line at the beginning of any mail message. These header lines are retained when the message is saved; they are just not shown when the message is displayed. See also ignore and retain.

dp [refs

deletes the specified messages, then displays the message after the last message deleted. If there is no subsequent message, mailx displays its command prompt.

dt [refs

is the same as the dp command.

ec[ho] string ... 

echoes the given strings (like the echo command).

e[dit] [refs

lets you edit the messages specified by refs. The messages are stored in a temporary file and an editor is invoked to let you edit the file. The default editor is ed, but you can change this using the EDITOR environment variable (see the ENVIRONMENT VARIABLES section).

ex[it

quits mailx without changing the system mailbox. Contrast this with quit which ordinarily removes from the system mailbox those messages you've read, saved or deleted.

fi[le] [filename

quits the current mailbox (as if a q[uit] command was executed), then reads in the specified file as the new mailbox to examine. If no filename is specified, mailx displays the name and status of your current mailbox.

Several special strings can be used in place of filename:

% your system mailbox
%user the system mailbox for user
# the previous file
& your current mbox
+file the named file in the folder directory

fold[er] [filename

is the same as the file command.

folders 

displays the names of the files in the directory given by the folder variable; see the ENVIRONMENT VARIABLES section.

F[ollowup] [refs

replies to the first message given in the refs; mailx sends this reply to the authors of every message given in the refs. The Subject line is taken from the first message in the refs. mailx automatically saves your reply in a file which derives its name from the author of the message to which you are replying.

To create your reply, mailx puts you into input mode, where you can use all of the input mode commands.

fo[llowup] [ref

replies to the specified message; if no message ref is given, you reply to the current message. mailx automatically saves your reply in a file which derives its name from the author of the original message. This overrides the record environment variable if it is set; see the ENVIRONMENT VARIABLES section.

To create your reply, mailx puts you into input mode, where you can use all of the input mode commands.

f[rom] [refs

displays the header summary for the specified messages. If no refs are given, the current message is used.

g[roup] [alias [name ...]] 

is the same as the alias command.

h[eaders] [ref

displays the headers of a screenful of messages including the message given by ref. The number of lines in a screen is given by the screen environment variable; see the ENVIRONMENT VARIABLES section.

hel[p

displays a summary of these commands.

ho[ld] [refs

retains the specified messages in your system mailbox. For example, you might decide to hold a message if you read it, but decide not to act upon it immediately. If no refs are specified, the current message is held. If any of the specified messages have been marked as deleted, the hold command overrides that and still retains the messages. Subsequent delete, dp, and dt commands during the same mailx session can delete files marked for retention. See also the environment variables hold and keepsave.

i[f] code 
mailx commands 
[el[se
mailx commands
en[dif

is primarily intended for use in start-up files; see the Start-Up Files section for information. The code must be the character r or s. If it is r, the first set of mailx commands are executed if mailx is in receive mode, and the second set if mailx is in send mode. If code is s, the opposite is true. The else part is optional.

ig[nore] [header ...] 

is the same as the discard command.

l[ist

displays the names of all command mode commands.

m[ail] address ... 

sends a message to the specified recipients. mailx goes into input mode to let you enter the text of the message.

mb[ox] [refs

indicates that the given messages are to be saved in your mbox when mailx quits normally (that is, through the quit command as opposed to exit).

n[ext] [refs

goes to the next message in the mailbox that appears in the list of refs. For example,

n user

goes to the next message from the specified user.

pi[pe] [[refs] command

pipes the messages given by refs through the specified shell command (run by the command interpreter identified by SHELL) These messages are considered read. If no refs are given, the current message is used. If no command is given, mailx uses the command given by the cmd environment variable; see the ENVIRONMENT VARIABLES section. If the page variable has a value, a formfeed is sent into the pipe after every message. The command

| [refs] [command]

is equivalent to pipe.

pre[serve] [refs

is the same as the hold command.

P[rint] [refs

displays the specified messages on the screen. If no refs are given, the current message is displayed. All header fields are displayed; the discard and ignore commands do not affect Print. If the crt variable is set to an integer, messages with more lines than that integer are paginated using the command specified by the PAGER variable. For more information, see the ENVIRONMENT VARIABLES section.

p[rint] [refs

displays the specified messages on the screen. If no refs are given the current message is displayed. Header fields specified by discard and ignore commands are not displayed.

q[uit

terminates a mailx session. This is the usual method to leave mailx. Messages that have been read but not saved or deleted are stored in your mbox. Messages that are still unread are retained in your system mailbox. Messages that have been deleted or explicitly saved in other files are discarded. Typing the EOF character has the same effect.

R[eply] [refs

sends a reply to the authors of each of the messages specified by refs. If no refs are specified, the current message is used. The Subject line of the reply message is taken from the first message in refs. If the record environment variable is set to a file name, your reply message is appended to the end of that file.

Normally, you use Reply if you just want to send your reply to the author of a message, and reply if you want to send your reply to the author and all recipients. If set, the flipr variable reverses the meanings of the R and r commands. See the ENVIRONMENT VARIABLES section.

r[eply] [ref

sends a reply to the author of a specific message, and all other recipients of the message. If no ref is specified, mailx replies to the current message. If the record environment variable is set to a file name, your reply message is appended to the end of that file.

R[espond] [refs

is the same as the Reply command.

r[espond] [ref

is the same as the reply command.

ret[ain] [header ...] 

is the opposite of the discard command. It tells mailx to display the given header fields when displaying a message. The comparison of header fields is not case sensitive. You can use retain to override existing discard and ignore commands. If you do not specify any header fields, retain displays a list of currently retained header fields.

S[ave] [refs

saves the specified messages in a file the name of which is taken from the author of the first message (the file name is the author's name, without any attached network addressing). If the folder variable is set, the file is saved to the specified directory.

s[ave] [refs] [filename

saves the specified messages in the given file. If no refs are given, the current message is added to the mbox. (The value of append variable determines whether the message is added to the beginning or end of the mbox.) The file is created if it doesn't already exist. If you do not specify filename, mailx saves the messages in mbox. A message that has been saved with save is normally deleted from mailbox when mailx terminates (see quit); but see the variables hold and keepsave.

se[t] [name

defines a variable with the given name and assigns it a null value. If you omit name, set displays a list of all defined variables and their values.

se[t] name=value 

defines a variable with the given name and assigns it the given value. The value may be a string or a number. If value contains white space, it must be quoted. You cannot use nested quotes within value.

se[t] noname 

is the same as the unset name command.

sh[ell

invokes the shell given by the SHELL environment variable.

si[ze] [refs

displays the size in bytes of each of the specified messages. If no refs are specified, the current message is used.

so[urce] file 

reads the specified text file, executes its contents as command mode commands, then returns to read more commands from the original source.

to[p] [refs

displays the first few lines of each of the specified messages. If no refs are specified, the current message is used. If the toplines variable has a numeric value, then a number of lines equal to this value are displayed from each message; otherwise, five lines are displayed from each message.

tou[ch] [refs

touches the specified messages, making them appear to have been read. This means that when you quit mailx, the messages are saved in your mbox if they are not deleted or explicitly saved in another file. If no refs are specified, the current message is touched.

T[ype] [refs

is the same as the Print command.

t[ype] [refs

is the same as the print command.

una[lias] [alias [name ...]] 

deletes specified alias names.

u[ndelete] [refs

restores previously deleted messages. When messages are deleted, they are not discarded immediately; they are just marked for deletion, and are actually deleted when mailx terminates. Until termination, you can use undelete to restore the specified messages. You cannot undelete messages deleted in previous sessions. If you do not give refs, this command restores the first deleted (but not yet undeleted) message following the current message; if no such message exists, it restores the last deleted (but not yet undeleted) message preceding the current message. If the autoprint variable is set, the last restored message is printed. This is the only command that lets you give a ref to a message which has been deleted.

U[nread] [refs

marks the specified messages as unread.

uns[et] name ... 

discards the specified variables.

ve[rsion

displays version information about mailx.

v[isual] [refs

edits the specified messages with a screen editor. If no refs are specified, the current message is edited. The messages are saved in a temporary file and the screen editor is invoked to edit that file. The editor used is given by the VISUAL variable; see the ENVIRONMENT VARIABLES section.

w[rite] [refs] filename 

writes the specified messages into the given file. If no refs are given, the current message is written. write is the same as save except that it does not write out the header lines and the blank line at the end of the message.

x[it

is the same as the exit command.

z[+

scrolls the header display forward one screenful.

z[-

scrolls the header display backward one screenful.

! command 

executes the given shell command. For example,

!lc

lists all files in the current directory. The shell that is invoked to execute the command is given by the SHELL environment variable; see the ENVIRONMENT VARIABLES section.

#comment 

mailx ignores everything from the # to the end of the line. This is useful for putting comments into start-up files.

? 

displays a summary of command mode commands.

= 

displays the current message number.

Input Mode Commands

You may use input mode commands when entering the text of a message. Input mode commands must appear at the beginning of an input line; they cannot be in the middle of a line. By default, each input mode command begins with the tilde (~) character, called the escape character. You may use the escape environment variable to change the escape character, but the documentation that follows uses tilde.

~A 

inserts the autograph string at this point in the message. This autograph string is given by the Sign environment variable.

~a 

is similar to ~A, except that it uses the variable sign.

~b name ... 

adds the specified names to the blind carbon copy list.

~c name ... 

adds the specified names to the carbon copy list.

~d 

reads in the dead.letter file; see the description of DEAD in the ENVIRONMENT VARIABLES section.

~e 

invokes an editor on the message that you have composed. The EDITOR variable determines the editor that is invoked.

~F [refs

forwards the given messages. The text of the messages is inserted at this point in the message that you are composing. The message headers are also inserted with all header fields regardless of the discard, ignore, and retain commands. This is only valid when you entered mailx in command mode, then went into input mode to compose a message.

~f [refs

is similar to ~F except that the header fields included are determined by the discard, ignore, and retain commands.

~h 

prompts you to enter the following header lines:

Subject   Cc   Bcc   To

For some of these, mailx displays an initial value for the header. You can edit this initial value as if you had just typed it in yourself, using backspaces and line deletes.

~i name 

inserts the value of the named variable followed by a newline at this point in the message.

~M [refs

inserts the text of the specified messages at this point in the message. If no refs are specified, the current message is used. Messages inserted in this way have each line prefixed with the value of the indentprefix variable. The message headers are also inserted with all header fields included regardless of the discard, ignore, and retain commands. This is only valid when you entered mailx in command mode, then went into input mode to reply to a message.

~m 

is similar to ~M except that the header fields included are determined by the discard, ignore, and retain commands.

~p 

displays the message being composed.

~q 

quits input mode as if you had interrupted the message. If you have already composed part of a message, the partial message is saved in the dead.letter file; see the description of the DEAD environment variable for more information.

~r filename 

reads in the contents of the specified file and adds that text at this point in the message.

~s text 

sets the Subject line to the given text.

~t address address ... 

adds the given addresses to the To: list (people who are to receive the message).

~v 

invokes a screen (visual) editor on the message that you have composed. The VISUAL variable determines the editor that is invoked.

~w file 

writes the current text of your message to the specified file. The header lines for the message are not written.

~x 

quits in the same way as ~q, except that the message is not saved in the dead.letter file.

~< filename 

is the same as the ~r command.

~< !command 

executes the given shell command and adds the standard output of that command at this point in the message. For example, your message might contain

 My program is giving me this odd output:
 ~< !prog
 What do you think is causing it?
~| command 

pipes the current message through the specified shell command. If the command terminates with a successful exit status, the output of the command replaces the text of the current message. For example,

~|fmt

fills and justifies the lines of your message and replaces the message with the formatted message. ~| uses the shell given by the SHELL environment variable to run command.

~! command 

executes the given shell command. For example,

~! lc

can be used to obtain a list of files in the current directory. The shell that is invoked to execute the command is given by the SHELL environment variable; see the ENVIRONMENT VARIABLES section. If the bang variable is set, mailx replaces each unescaped exclamation mark (!) in command with the command executed by the previous ! command or ~! command escape.

~. 

marks the end of input in a mail message.

~: mail_command 

executes the given command mode mail_command. This is only valid when you entered mailx in command mode, then went into input mode to compose a message.

~_ mail_command 

is the same as the ~: command.

~? 

displays a summary of the input mode commands.

Start-Up Files

When you invoke mailx in command mode, mailx does the following:

  1. Sets all variables to their default values.
  2. Processes command-line options, using them to override any corresponding default values.
  3. Imports appropriate external environment variables, using them to override any corresponding default values.
  4. Reads commands from ROOTDIR/etc/mailx.rc, the system start-up file. This sets up variable values and definitions that should be common to all users. If you do not want mailx to read the system start-up file, use the -n option on the mailx command line.
  5. Reads your personal start-up file, given by the environment variable MAILRC. By default, this is the mail.rc file, under your home directory. On UNIX and POSIX-compliant systems, the name of the file is .mailrc.

Typically, start-up files set up display options and define aliases; however, any command is valid in a start-up file except for the following:

Copy          edit          followup      Followup
mail          hold          preserve      reply
Reply         respond       Respond       shell
visual        !

If a line in a start-up file contains an error or an invalid command, the rest of the start-up file is ignored. mailx ignores blank lines in a start-up file.


EXAMPLES

The following example composes and sends a message to several users. Items shown in italics are output by mailx itself.

mailx jean
Subject: Greetings
This is just a short note to say hello.
~c juan john johann
~.

On the first line, the message is just addressed to jean. The ~c line adds more people who are to receive copies of the message.


ENVIRONMENT VARIABLES

A large number of variables control the behavior of mailx. These environment variables are divided into two classes: ones which always come from the external environment; and ones that may be set up in either the external environment or within a mailx session.

The following variables always come from the external environment; these can be changed inside a mailx session, except where marked.

HOME 

gives the name of your home directory. This cannot be changed inside mailx.

LOGNAME 

gives your login name. If no name is specified, mailx uses the default login name mks.

MAILDIR 

gives the name of the directory where system mailboxes are stored. If this is not set, the default is ROOTDIR/usr/mail. The actual name of a user's system mailbox is derived in a system-dependent way by combining MAILDIR and the user's login name (username). For mailx to work properly, the MAILDIR directory must exist.

MAILRC 

gives the name of your start-up file. This cannot be changed inside mailx. By default, MAILRC has the value $HOME/.mailrc on UNIX, and $HOME/mail.rc on Windows systems. For more on start-up files, see the Start-Up Files section.

On Windows, LOGNAME derives its value from the environment variable username. If no directory exists at /users/$username, HOME defaults to /users/default.

The remaining variables may be set in the external environment or in the course of a mailx session. The value of a variable may be set or changed with the set command; a variable may be discarded with the unset command. It is often convenient to create a start-up file that sets these variables according to your preferences; this eliminates the need to set variables by hand every time you enter mailx.

Many of the following variables represent on/off options. If you set the variable itself (to any value), the option is turned on. To turn the option off, you may unset the variable, or set a variable consisting of no followed by the name of the original variable. For example, setting autoprint turns the autoprint option on, and setting noautoprint turns it off.

Note:

If you attempt to unset a variable before that variable is set, mailx displays a warning message.

allnet 

assumes that network addresses with the same login component refer to the same person. Network addresses typically consist of several components, giving information that lets a mail server identify a machine on the network, a route to that machine, and the login name of a user on that machine. mailx assumes that the login name is the last component. For example,

print name

displays all messages that originated from the same login name, regardless of the rest of the network address. The default is noallnet, where different addresses are assumed to be different users, even if the login name components are the same.

append 

appends messages to the end of the mbox file upon termination. The default is noappend; messages are placed at the beginning of the mbox file instead of the end.

ask 

prompts you for a Subject: line when composing a message (if you have not already specified one with the -s option). This option is turned on by default; to turn it off, set noask.

askbcc 

prompts you for a Bcc: list when composing a message. The default is noaskbcc; you are not prompted.

askcc 

prompts you for a Cc: list when composing a message. The default is noaskcc; you are not prompted.

asksub 

is the same as ask. noasksub is the same as noask.

autoprint 

displays the next message automatically when you delete a message, and displays messages as you undelete them. The default is noautoprint; you are not shown messages that you delete or undelete.

bang 

records shell commands executed inside the mailx session (for example, through the ~! input mode command). Then, if you issue a shell command and the shell command contains a ! character, mailx replaces that character with the command line for the previous shell command. The default is nobang, in which case a ! in a shell command line is not treated specially.

cmd 

contains a command, possibly with options. This specifies a default command line to be used for the command mode pipe command. For example,

set cmd="more"

pipes messages through more when the pipe command is invoked.

conv 

specifies that UUCP network addresses are to be converted to a different style. The conv variable is assigned a code word indicating the desired style. At present, the only code word recognized is internet, which stands for the RFC822 specifications for network mail addressing. By default, conv is not defined and no conversion takes place.

crt 

contains an integer number. If a message has more than this number of lines, mailx pipes the message through the command given by the PAGER variable, whenever it displays the message. If this variable is set to null, mailx treats it as a value of zero and pipes all messages through PAGER. The default is nocrt.

DEAD 

contains the name of a file that can be used as the dead.letter file. Partial messages are saved in this file if an interrupt or error occurs during creation of the message or delivery. By default, the name of this file is $HOME/dead.letter on UNIX, and $HOME/dead.let on windows systems.

dot 

accepts a line consisting of only a dot (.) as the end of a message in input mode (it is equivalent to ~.). The default is nodot. If ignoreeof is set, mailx ignores a setting of nodot; the dot is the only way to terminate input mode.

EDITOR 

gives a command, possibly with options, that is invoked when using the command mode edit or the input mode ~e. The default is the ed utility (see ed).

escape 

gives the character used to begin input mode commands. The default is the tilde (~). If this variable is set to null, mailx disables command escaping.

flipr 

reverses the meanings of the R and r commands. The default is noflipr. See also Replyall.

folder 

contains the name of the directory in which mailx saves mail files. Whenever you specify a file name for a mailx command, putting a plus sign (+) in front of the name specifies that the file is to be accessed under the folder directory. If the value of folder begins with a slash, it is taken as an absolute path name; otherwise, mailx assumes that the directory is directly under your HOME directory. folder has no default value. If it is not set, the plus sign (+) has no special meaning at the beginning of file names.

header 

displays a summary of message headers at the beginning of a mailx command mode session. This is the default.

hold 

keeps all messages in your system mailbox instead of saving them in your mbox. The default is nohold.

ignore 

ignores interrupts received while composing a message. The default is noignore.

ignoreeof 

ignores EOF markers found while entering a message. The message can be ended by a dot (.) or ~. on a line by itself. The default is noignoreeof.

indent 

contains a string that mailx uses as a prefix to each line in messages that ~m and ~M insert. The default is one <tab> character.

indentprefix 

the same as indent, contains a string that mailx uses as a prefix to each line in messages that ~m and ~M insert. The default is one <tab> character. If both indent and indentprefix are set, indentprefix takes precedence.

keep 

does not remove your system mailbox if the mailbox contains no messages. The mailbox is truncated to zero length. If the default nokeep is in effect, empty mailboxes are removed.

keepsave 

keeps messages in your system mailbox even if they have been saved in other files. The default, nokeepsave, deletes messages from the mailbox if they have been saved elsewhere.

LISTER 

contains a command, possibly with options. mailx invokes this command when displaying the contents of the folder directory for the folders command. If this variable is null or unset, mailx uses the ls utility. By default, this variable is unset.

MAILRC 

location of personal start-up file. See Start-Up Files.

MBOX 

gives the name of your mbox file. Messages that have been read but not saved elsewhere are saved here when you quit (but not when you exit). The default is $HOME/mbox.

metoo 

when replying to a message with your login name in the recipient list, sends a reply to all other recipients, the author and you. If nometoo is set, you are not sent the reply. The default is nometoo.

msexchange 

when set,Microsoft Exchange compatibility mode is used. In this mode, the From line is:

From: username

and the Date line is

Date: DayofWeek, DayofMonth Mon Year HH:MM:SS timezoneoffset
onehop 

attempts to send replies directly to the recipients instead of going through the original author's machine. When you reply to a message, your reply is sent to the author and all recipients of the message. On a network, mailx normally specifies the recipient addresses so that the replies all go to the original author's machine first, then on to the other recipients.

outfolder 

causes files used to record outgoing messages (see the description of record) to be located in the directory given by folder unless folder contains an absolute path name. The default is nooutfolder.

page 

tells the pipe command to insert a formfeed character after each message that it sends through the pipe. The default is nopage.

PAGER 

contains a command, possibly including options. mailx sends display output through this command if the output is longer than the screen length given by crt. The default is the more utility (see more).

prompt 

contains a string that mailx displays to prompt for output in command mode. The default is a question mark followed by a space (? ).

quiet 

does not display the opening message and version number when mailx begins a session. The default is noquiet.

record 

contains a file name where mailx records every message you send. If record is not an absolute path name and the outfolder variable has not been set, the file is located under the current directory. If the outfolder variable is set, the file is located in your folder directory. The default is norecord.

Replyall 

reverses the senses of the reply and Reply commands (so that reply only replies to the author of a message, and Reply replies to the author and all other recipients). See also flipr.

save 

saves messages in your dead.letter file if they are interrupted while being composed. The name of your dead.letter file is given by the DEAD variable. Setting nosave disables this automatic save feature. The default is save.

screen 

gives the number of headers that are to be displayed by the headers and z commands.

sendmail 

contains a command, possibly with options, that mailx invokes to send mail. You must manually set the default for this environment variable by editing ROOTDIR/etc/mailx.rc to specify the mail agent of your choice. The default is sendmail, but it can be any command that takes addresses on the command line and message contents on standard input. This command should always be specified as a full absolute path name including extension. For example:

set sendmail=c:/mks/mksnt/smtpmail.exe

works but the following do not:

set sendmail=smptmail
set sendmail=c:/mks/mknst/smptmail

You cannot use any environment variables in this path name as such variables are not expanded.

Note:

Because you cannot include nested quotes within a variable's value, you cannot pass any arguments to the specified command that would require quoted white space.

sendwait 

when sending a message through a network, mailx waits for the mail server to finish before returning to your session. Normally, it just submits the message to the server, then returns immediately. The default is nosendwait.

SHELL 

contains a command, possibly with options. mailx assumes that this command is a command interpreter. mailx invokes this command interpreter whenever it is asked to execute a system command (for example, through the ! command mode command). The default is the MKS KornShell (see sh).

showto 

when displaying a header summary, displays the recipient's name instead of the author's for messages where you are the author. The default is noshowto.

sign 

contains a string that is inserted into a message when you use the input mode ~a command. mailx interprets \n and \t in this string as the newline and tab characters, respectively. The default is nosign.

Sign 

contains a string that is inserted into a message when you use the input mode ~A command. The default is noSign.

toplines 

gives the number of header lines that the top command displays. The default is five.

TERM 

contains the name of the terminal type. If screen is not set, TERM individually determines the number of lines in a screenful of headers.

VISUAL 

contains a command, possibly with options, that mailx invokes when using the command mode visual or the input mode ~v. The default is the vi utility (see vi).


FILES

ROOTDIR/etc/mailx.rc 

System-wide start-up file.

$MAILRC 

Personal start-up file. By default, MAILRC has the value $HOME/mail.rc.

$HOME/mbox 

Default location to save read messages. You can choose a different file by assigning the file name to the environment variable MBOX.

$MAILDIR 

Directory containing system mailboxes. By default, this is ROOTDIR/usr/mail. You must create the $MAILDIR directory if it does not already exist.

$HOME/dead.letter 

Default location to save partial letters. On Windows systems, this is truncated to $HOME/dead.let.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion. Also returned if -e is specified and there is new or unread mail.

1 

Returned if -e is specified and there is no new or unread mail. Also returned to indicate failure because of any of the following:

— there is no mail to read
— inability to create temporary file name or temporary file
— receipt of user interrupt while composing message
— inability to determine the user's identity
2 

Failure due to any of the following:

— missing number after -h
— missing address after -r
— missing subject after -s
— missing user after -u
— invalid command line option
— use of interactive options when not using command interactively


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. UNIX System V. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. Windows Server 2025.

UNIX System V has a compatible mailx utility while Berkeley systems have a similar utility known as Mail.

The -F, -r, and -U options, the Copy, echo, followup, Followup, Save, Unread, and version commands, and the allnet, conv, onehop, replyall, sendmail, and sendwait variables are extensions to the POSIX standard.


NOTES

For mailx to work properly, you must define the environment variables HOME and LOGNAME. On Windows systems, LOGNAME derives its value from the environment variable username. If no directory exists at ROOTDIR/users/$username, then HOME is set to ROOTDIR/users/default. Also, the ROOTDIR/usr/mail directory must exist or else the environment variable MAILDIR must give the name of an existing directory.


AVAILABILITY

PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
echo, ed, fmt, mapimail, pg, sh, smtpmail, vi


PTC MKS Toolkit 10.5 Documentation Build 40.