The mail utilities listed above provide a comfortable, flexible environment for sending and receiving mail messages electronically.
When reading mail, the mail utilities provide commands to facilitate saving, deleting, and responding to messages. When sending mail, the mail utilities allow editing, reviewing and other modification of the message as it is entered.
Incoming mail is stored in a standard file for each user, called the mailbox for that user. When the mail utilities are 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 in 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. 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.
On the command line options start with a dash (-). Any other arguments are taken to be destinations (recipients). If no recipients are specified, mailx attempts to read messages from the mailbox.
Do not buffer standard input or standard output.
Set the blind carbon copy list to bcc. bcc should be enclosed in quotes if it contains more than one name.
Set the carbon copy list to cc. cc should be enclosed in quotes if it contains more than one name.
Turn on debugging output. (Neither particularly interesting nor recommended.)
Test for the presence of mail. mailx prints nothing and exits with a successful return code if there is mail to read.
Record the message in a file named after the first recipient. Overrides the record variable, if set (see Internal Variables).
Read messages from file instead of mailbox. If no file is specified, the mbox is used.
Use the file folder in the folder directory (same as the folder command). The name of this directory is listed in the folder variable.
Print header summary only.
The number of network “hops” made so far. This is provided for network software to avoid infinite delivery loops. This option and its argument are passed to the delivery program.
Include the newsgroup and article-id header lines when printing mail messages. This option requires the -f option to be specified.
Ignore interrupts. See also ignore in Internal Variables.
Do not print initial header summary.
Do not initialize from the system default mailx.rc or Mail.rc file. See USAGE.
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.
Set the Subject header field to subject. subject should be enclosed in quotes if it contains embedded white space.
Message-id and article-id header lines are recorded in file after the message is read. This option also sets the -I option.
Scan the input for To:, Cc:, and Bcc: fields. Any recipients on the command line will be ignored.
Convert UUCP-style addresses to internet standards. Overrides the conv environment variable.
Read user's mailbox. This is only effective if user's mailbox is not read protected.
Print the mailx version number and exit.
Pass the -v flag to sendmail(1M).
Interpret tilde escapes in the input even if not reading from a tty.
At startup time, mailx executes the system startup file /etc/mail/mailx.rc. If invoked as mail or Mail, the system startup file /etc/mail/Mail.rc is used instead.
The system startup file sets up initial display options and alias lists and assigns values to some internal variables. These variables are flags and valued parameters which are set and cleared using the set and unset commands. See Internal Variables.
With the following exceptions, regular commands are legal inside startup files: !, Copy, edit, followup, Followup, hold, mail, preserve, reply, Reply, shell, and visual. An error in the startup file causes the remaining lines in the file to be ignored.
After executing the system startup file, the mail utilities execute the optional personal startup file $HOME/.mailrc, wherein the user can override the values of the internal variables as set by the system startup file.
If the -n option is specified, however, the mail utilities do not execute the system startup file.
Many system administrators include the commands
set appenddeadletter unset replyall unset pipeignore
in the system startup files (to be compatible with past Solaris behavior), but this does not meet standards requirements for mailx. To get standard behavior for mailx, users should use the -n option or include the following commands in a personal startup file:
unset appenddeadletter set replyall set pipeignore
When reading mail, the mail utilities are in command mode. A header summary of the first several messages is displayed, followed by a prompt indicating the mail utilities can accept regular commands (see Commands below). When sending mail, the mail utilities are in input mode. If no subject is specified on the command line, and the asksub variable is set, a prompt for the subject is printed.
As the message is typed, the mail utilities read 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.
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 (message-list) to operate on. In most cases, the current message is set to the highest-numbered message in the list after the command is finished executing.
The default for message-list is the current message. A message-list is a list of message identifiers separated by spaces, which may include:
Message number n.
The current message.
The first undeleted message.
The last message.
The next undeleted message.
The previous undeleted message.
An inclusive range of message numbers.
All messages from user.
All messages with string in the Subject line (case ignored).
Notice 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 using the normal shell conventions (see sh(1)). Special characters are recognized by certain commands and are documented with the commands below.
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) or in a system startup file (for example, $HOME/.mailrc). Aliases are lists of recipients of any type.
To forward a specific message, include it in a message to the desired recipients with the ~f or ~m tilde escapes. See Tilde Escapes below. To forward mail automatically, add a comma-separated list of addresses for additional recipients to the .forward file in your home directory. This is different from the format of the alias command, which takes a space-separated list instead. Note: Forwarding addresses must be valid, or the messages will “bounce.” You cannot, for instance, reroute your mail to a new host by forwarding it to your new address if it is not yet listed in the NIS aliases domain.
[ command ] [ message-list ] [ arguments ]
In input mode, commands are recognized by the escape character, tilde(~), and lines not treated as commands are taken as input for the message. If no command is specified in command mode, next is assumed. The following is a complete list of mailx commands:
Declare a list of alternate names for your login. When responding to a message, these names are removed from the list of recipients for the response. With no arguments, print the current list of alternate names. See also allnet in Internal Variables.
Change directory. If directory is not specified, $HOME is used.
Suppress printing of the specified header fields when displaying messages on the screen. Examples of header fields to ignore are Status and Received. The fields are included when the message is saved, unless the alwaysignore variable is set. The More, Page, Print, and Type commands override this command. If no header is specified, the current list of header fields being ignored is printed. See also the undiscard and unignore commands.
Echo the given strings (like echo(1)).
Edit the given messages. Each message is placed in a temporary file and the program named by the EDITOR variable is invoked to edit it (see ENVIRONMENT VARIABLES). Default editor is ed(1).
the current mailbox.
the mailbox for user.
the previous mail file.
the current mbox.
The named file in the folder directory (listed in the folder variable).
With no arguments, print the name of the current mail file, and the number of messages and characters it contains.
Respond to a message, recording the response in a file whose name is derived from the author of the message. Overrides the record variable, if set. If the replyall variable is set, the actions of Followup and followup are reversed. See also the followup, Save, and Copy commands and outfolder in Internal Variables, and the Starting Mail section in USAGE above.
Respond to the first message in the message-list, sending the message to the author of each message in the message-list. The subject line is taken from the first message and the response is recorded in a file whose name is derived from the author of the first message. If the replyall variable is set, the actions of followup and Followup are reversed. See also the Followup, Save, and Copy commands and outfolder in Internal Variables, and the Starting Mail section in USAGE above.
Print the header summary for the specified messages. If no messages are specified, print the header summary for the current message.
Conditional execution, where s executes following mail-commands, up to an else or endif, if the program is in send mode, r causes the mail-commands to be executed only in receive mode, and t causes the mail-commands to be executed only if mailx is being run from a terminal. Useful in the mailrc file.
Incorporate messages that arrive while you are reading the system mailbox. The new messages are added to the message list in the current mail session. This command does not commit changes made during the session, and prior messages are not renumbered.
Suppress printing of the specified header fields when displaying messages on the screen. Examples of header fields to ignore are Status and Cc. All fields are included when the message is saved. The More, Page, Print and Type commands override this command. If no header is specified, the current list of header fields being ignored is printed. See also the undiscard and unignore commands.
Mail a message to the specified recipients.
Mail a message to the specified recipients, and record it in a file whose name is derived from the author of the message. Overrides the record variable, if set. See also the Save and Copy commands and outfolder in Internal Variables.
Arrange for the given messages to end up in the standard mbox save file when mailx terminates normally. See MBOX in ENVIRONMENT VARIABLES for a description of this file. See also the exit and quit commands.
Print the specified messages. If crt is set, the messages longer than the number of lines specified by the crt variable are paged through the command specified by the PAGER variable. The default command is pg(1) or if the bsdcompat variable is set, the default is more(1). See ENVIRONMENT VARIABLES. Same as the print and type commands.
Go to the next message matching message. If message is not supplied, this command finds the next message that was not deleted or saved. A message-list may be specified, but in this case the first valid message in the list is the only one used. This is useful for jumping to the next message from a specific user, since the name would be taken as a command in the absence of a real command. See the discussion of message-list above for a description of possible message specifications.
Pipe the message through the given shell-command. The message is treated as if it were read. If no arguments are given, the current message is piped through the command specified by the value of the cmd variable. If the page variable is set, a form feed character is inserted after each message (see Internal Variables).
Print the specified messages. If crt is set, the messages longer than the number of lines specified by the crt variable are paged through the command specified by the PAGER variable. The default command is pg(1) or if the bsdcompat variable is set, the default is more(1). See ENVIRONMENT VARIABLES. Same as the more and page commands.
Send a response to the author of each message in the message-list. The subject line is taken from the first message. If record is set to a file, a copy of the reply is added to that file. If the replyall variable is set, the actions of Reply/Respond and reply/respond are reversed. The replysender command is not affected by the replyall variable, but sends each reply only to the sender of each message. See the Starting Mail section in USAGE above.
Reply to the specified message, including all other recipients of that message. If the variable record is set to a file, a copy of the reply added to that file. If the replyall variable is set, the actions of Reply/Respond and reply/respond are reversed. The replyall command is not affected by the replyall variable, but always sends the reply to all recipients of the message. See the Starting Mail section in USAGE above.
Add the list of header fields named to the retained list. Only the header fields in the retain list are shown on your terminal when you print a message. All other header fields are suppressed. The set of retained fields specified by the retain command overrides any list of ignored fields specified by the ignore command. The Type and Print commands can be used to print a message in its entirety. If retain is executed with no arguments, it lists the current set of retained fields.
Save the specified messages in a file whose name is derived from the author of the first message. The name of the file is taken to be the author's name with all network addressing stripped off. See also the Copy, followup, and Followup commands and outfolder in Internal Variables.
Save the specified messages in the given file. The file is created if it does not exist. The file defaults to mbox. The message is deleted from the mailbox when mailx terminates unless keepsave is set (see also Internal Variables and the exit and quit commands).
Define a variable. To assign a value to variable, separate the variable name from the value by an `=' (there must be no space before or after the `='). A variable may be given a null, string, or numeric value. To embed SPACE characters within a value, enclose it in quotes.
Print the size in characters of the specified messages.
Touch the specified messages. If any message in message-list is not specifically saved in a file, it is placed in the mbox, or the file specified in the MBOX environment variable, upon normal termination. See exit and quit.
Print the specified messages. If crt is set, the messages longer than the number of lines specified by the crt variable are paged through the command specified by the PAGER variable. The default command is pg(1). See ENVIRONMENT VARIABLES.
Edit the given messages with a screen editor. Each messages is placed in a temporary file and the program named by the VISUAL variable is invoked to edit it (see ENVIRONMENT VARIABLES). Notice that the default visual editor is vi.
Scroll the header display forward or backward one screen-full. The number of headers displayed is set by the screen variable (see Internal Variables).
The following tilde escape commands can be used when composing mail to send. These may be entered only from input mode, by beginning a line with the tilde escape character (~). See escape in Internal Variables for changing this special character. The escape character can be entered as text by typing it twice.
Escape to the shell. If present, run shell-command.
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 Sign into the message (see Internal Variables).
Insert the autograph string sign into the message (see Internal Variables).
Add the names to the blind carbon copy (Bcc) list. This is like the carbon copy (Cc) list, except that the names in the Bcc list are not shown in the header of the mail message.
Add the names to the carbon copy (Cc) list.
Read in the dead-letter file. See DEAD in ENVIRONMENT VARIABLES for a description of this file.
Invoke the editor on the partial message. See also EDITOR in ENVIRONMENT VARIABLES.
Forward the specified message, or the current message being read. Valid only when sending a message while reading mail. The messages are inserted into the message without alteration (as opposed to the ~m escape).
Forward the specified message, or the current message being read, including all header fields. Overrides the suppression of fields by the ignore command.
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 Sign.' Environment variables set and exported in the shell are also accessible by ~i.
Insert the listed messages, or the current message being read into the letter. Valid only when sending a message while reading mail. The text of the message is shifted to the right, and the string contained in the indentprefix variable is inserted as the leftmost characters of each line. If indentprefix is not set, a TAB character is inserted into each line.
Insert the listed messages, or the current message being read, including the header fields, into the letter. Valid only when sending a message while reading mail. The text of the message is shifted to the right, and the string contained in the indentprefix variable is inserted as the leftmost characters of each line. If indentprefix is not set, a TAB character is inserted into each line. Overrides the suppression of fields by the ignore command.
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 dead-letter. See DEAD in ENVIRONMENT VARIABLES for a description of this file.
Mark message for return receipt.
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 string.
Add the given names to the To list.
Invoke a preferred screen editor on the partial message. The default visual editor is vi(1). See also VISUAL in ENVIRONMENT VARIABLES.
Write the message into the given file, without the header.
Exit as with ~q except the message is not saved in dead-letter.
Pipe the body of the message through the given shell-command. If the shell-command returns a successful exit status, the output of the command replaces the message.
The following variables are internal variables. They may be imported from the execution environment or set using the set command at any time. The unset command may be used to erase variables.
All network names whose last component (login name) match are treated as identical. This causes the message-list message specifications to behave similarly. Disabled by default. See also the alternates command and the metoo and fuzzymatch variables.
Ignore header fields with ignore everywhere, not just during print or type. Affects the save, Save, copy, Copy, top, pipe, and write commands, and the ~m and ~f tilde escapes. Enabled by default.
Upon termination, append messages to the end of the mbox file instead of prepending them. Although disabled by default, append is set in the system startup file (which can be suppressed with the -n command line option).
Append to the deadletter file rather than overwrite it. Although disabled by default, appenddeadletter is frequently set in the system startup file. See Starting Mail in USAGE above.
Prompt for the Bcc list after the Subject is entered if it is not specified on the command line with the -b option. Disabled by default.
Prompt for the Cc list after the Subject is entered if it is not specified on the command line with the -c option. Disabled by default.
Prompt for subject if it is not specified on the command line with the -s option. Enabled by default.
Automatically incorporate new messages into the current session as they arrive. This has an affect similar to issuing the inc command every time the command prompt is displayed. Disabled by default, but autoinc is set in the default system startup file for mailx; it is not set for /usr/ucb/mail or /usr/ucb/Mail.
Enable automatic printing of messages after delete and undelete commands. Disabled by default.
Enable the special-casing of exclamation points (!) in shell escape command lines as in vi(1). Disabled by default.
Set automatically if mailx is invoked as mail or Mail. Causes mailx to use /etc/mail/Mail.rc as the system startup file. Changes the default pager to more(1).
Set the default command for the pipe command. No default value.
Convert uucp addresses to the specified address style, which can be either:
This requires a mail delivery program conforming to the RFC822 standard for electronic mail addressing.
Remove loops in uucp(1C) address paths (typically generated by the reply command). No rerouting is performed; mail has no knowledge of UUCP routes or connections.
Conversion is disabled by default. See also sendmail(1M) and the -U command-line option.
Pipe messages having more than number lines through the command specified by the value of the PAGER variable ( pg(1) or more(1) by default). If number is not specified, the current window size is used. Disabled by default.
Enable verbose diagnostics for debugging. Messages are not delivered. Disabled by default.
Take a period on a line by itself, or EOF during input from a terminal as end-of-file. Disabled by default, but dot is set in the system startup file (which can be suppressed with the -n command line option).
By default, mailx will treat any address containing a slash ("/") character as a local "send to file" address. By unsetting this option, this behavior is disabled. Enabled by default.
Reverse the effect of the followup/Followup and reply/Reply command pairs. If both flipr and replyall are set, the effect is as if neither was set.
Extract the author listed in the header summary from the From: header instead of the UNIX From line. Enabled by default.
The from command searches for messages from the indicated sender. By default, the full sender address must be specified. By setting this option, only a sub-string of the sender address need be specified. Disabled by default.
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 directory does not start with a slash (/), $HOME is prepended to it. There is no default for the folder variable. See also outfolder below.
Enable printing of the header summary when entering mailx. Enabled by default.
Preserve all messages that are read in the mailbox instead of putting them in the standard mbox save file. Disabled by default.
Ignore interrupts while entering messages. Handy for noisy dial-up lines. Disabled by default.
Ignore end-of-file during message input. Input must be terminated by a period (.) on a line by itself or by the ~. command. See also dot above. Disabled by default.
When indentprefix is set, string is used to mark indented lines from messages included with ~m. The default is a TAB character.
When the mailbox is empty, truncate it to zero length instead of removing it. Disabled by default.
The specified prompt string is displayed before each line on input is requested when sending a message.
Keep messages that have been saved in other files in the mailbox instead of deleting them. Disabled by default.
When replying to all recipients of a message, if an address does not include a machine name, it is assumed to be relative to the sender of the message. Normally not needed when dealing with hosts that support RFC822.
If your login appears as a recipient, do not delete it from the list. Disabled by default.
Force all mail addresses to be in bang format.
When responding to a message that was originally sent to several recipients, the other recipient addresses are normally forced to be relative to the originating author's machine for the response. This flag disables alteration of the recipients' addresses, improving efficiency in a network where all machines can send directly to all other machines (that is, one hop away). Disabled by default.
Locate the files used to record outgoing messages in the directory specified by the folder variable unless the path name is absolute. Disabled by default. See folder above and the Save, Copy, followup, and Followup commands.
Used with the pipe command to insert a form feed after each message sent through the pipe. Disabled by default.
Omit ignored header when outputting to the pipe command. Although disabled by default, pipeignore is frequently set in the system startup file. See Starting Mail in USAGE above.
Your "real name" to be included in the From line of messages you send. By default this is derived from the comment field in your passwd(4) file entry.
Set the command mode prompt to string. Default is “? ”, unless the bsdcompat variable is set, then the default is “&”.
Refrain from printing the opening message and version when entering mailx. Disabled by default.
Record all outgoing mail in file. Disabled by default. See also outfolder above.
Reverse the effect of the reply and Reply and followup and Followup commands. Although set by default, replayall is frequently unset in the system startup file. See flipr and Starting Mail in USAGE above.
The default sender address is that of the current user. This variable can be used to set the sender address to any arbitrary value. Set with caution.
Enable saving of messages in dead-letter on interrupt or delivery error. See DEAD for a description of this file. Enabled by default.
Sets the number of lines in a screen-full of headers for the headers command. number must be a positive number.
The default is set according to baud rate or window size. With a baud rate less than 1200, number defaults to 5, if baud rate is exactly 1200, it defaults to 10. If you are in a window, number defaults to the default window size minus 4. Otherwise, the default is 20.
Alternate command for delivering messages. Note: In addition to the expected list of recipients, mail also passes the -i and -m, flags to the command. Since these flags are not appropriate to other commands, you may have to use a shell script that strips them from the arguments list before invoking the desired command. Default is /usr/bin/rmail.
Wait for background mailer to finish before returning. Disabled by default.
Causes the message header display to show the sender's real name (if known) rather than their mail address. Disabled by default, but showname is set in the /etc/mail/mailx.rc system startup file for mailx.
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 in Tilde Escapes).
The variable inserted into the text of a message when the ~A command is given. No default (see also ~i in Tilde Escapes).
The number of lines of header to print with the top command. Default is 5.
Invoke sendmail(1M) with the -v flag.
the postmark for the sender (see the postmark variable)
translated mail addresses, one per line, corresponding to the program's arguments. Each translated address will replace the corresponding address in the mail message being sent.
a line containing only "y" or "n". if the line contains "y" the user will be asked to confirm that the message should be sent.
The translate program will be invoked for each mail message to be sent. If the program exits with a non-zero exit status, or fails to produce enough output, the message is not sent.
See largefile(5) for the description of the behavior of mailx when encountering files greater than or equal to 2 Gbyte ( 231 bytes).
See environ(5) for descriptions of the following environment variables that affect the execution of mailx: HOME, LANG, LC_CTYPE, LC_TIME, LC_MESSAGES, NLSPATH, and TERM.
The name of the file in which to save partial letters in case of untimely interrupt. Default is $HOME/dead.letter.
The command to run when the edit or ~e command is used. Default is ed(1).
The command (and options) to use when listing the contents of the folder directory. The default is ls(1).
The name of the initial mailbox file to read (in lieu of the standard system mailbox). The default is /var/mail/username .
The name of the startup file. Default is $HOME/.mailrc.
The specified string is included at the beginning of the body of each message that is sent.
The specified string is included at the end of the body of each message that is sent.
The name of the file to save messages which have been read. The exit command overrides this function, as does saving the message explicitly in another file. Default is $HOME/mbox.
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), or if the bsdcompat variable is set, the default is more(1). See Internal Variables.
The name of a preferred command interpreter. Default is sh(1).
The name of a preferred screen editor. Default is vi(1).
When the -e option is specified, the following exit values are returned:
Mail was found.
Mail was not found or an error occurred.
Otherwise, the following exit values are returned:
Successful completion. Notice that this status implies that all messages were sent, but it gives no assurances that any of them were actually delivered.
An error occurred
personal startup file
secondary storage file
lock file to prevent multiple writers of system mailbox
optional system startup file for mailx only
BSD compatibility system-wide startup file for /usr/ucb/mail and /usr/ucb/Mail
help message files
post office directory
See attributes(5) for descriptions of the following attributes:
|ATTRIBUTE TYPE||ATTRIBUTE VALUE|
biff(1B), echo(1), ed(1), ex(1), fmt(1), lp(1), ls(1), mail(1), mail(1B), mailcompat(1), more(1), pg(1), sh(1), uucp(1C), vacation(1), vi(1), newaliases(1M), sendmail(1M), aliases(4), passwd(4), attributes(5), environ(5), largefile(5), standards(5)
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.
Replies do not always generate correct return addresses. Try resending the errant reply with onehop set.
mailx does not lock your record file. So, if you use a record file and send two or more messages simultaneously, lines from the messages may be interleaved in the record file.
To read mail on a workstation running Solaris 1.x when your mail server is running Solaris 2.x, first execute the mailcompat(1) program.