This description is divided into the following sections:
Introduction
Synopsis of mailx formats
Description of individual formats
Format 1: Read mode (from "mailx interactive message processing system (mail extended)")
mailx commands in read mode
Input format
Functional overview
Descriptions in alphabetical order
Functionality in read modeFormat 2: Send mode (from "mailx interactive message processing system (mail extended)")
mailx commands in send mode (tilde commands)
Input format
Functional overview
Descriptions in alphabetical order
Functionality in send mode
mailx command and startup files (from "mailx interactive message processing system (mail extended)")
Variables
mailx variables (from "mailx interactive message processing system (mail extended)")
Environment Variables (from "mailx interactive message processing system (mail extended)")
Note on error messages
Files
Examples
See also
Introduction
mailx enables you to send and receive electronic mail. If MAIL of the interNet Services (formerly interNet Value Edition) ist installed you can exchange messages with other users on the same system. The presence of mail, if any, is usually indicated when you log in. You are also notified if new mail arrives while you are using mailx. Messages have a message header holding information needed for message forwarding. The message header contains the following fields:
The header is followed by a blank line and then the text of the message. The mailx utility allows you to:
mailx automatically collects read messages in a user-specific mailbox ($HOME/mbox by default). |
Syntax
Synopsis of mailx formats
Format 1: |
mailx[ option] |
Format 2: |
mailx[ option]... recipient... |
Read mode
No option specified mailx behaves as described in Functionality in read mode.
mailx simply checks whether there are any messages, terminating with an exit status of 0 if the user has mail. Otherwise, an exit status of 1 is returned.
mailx reads messages from file. file not specified: -f file not specified:
(H - Header) mailx displays only the header summaries and terminates. The exit status is 0 if the user has mail, otherwise 1. The structure of a header summary is described in Functionality in read mode).
(i - ignore) mailx ignores the signal SIGINT (see the mailx variable ignore on "mailx interactive message processing system (mail extended)").
mailx does not initialize from the global startup file /etc/mail/mailx.rc (see “mailx command and startup files”).
mailx does not print the initial header summary.
mailx reads messages from the default mailbox of the specified user, provided you have
mailx displays its version number and exits. mailx commands in read modeInput format mailx commands in read mode have the following format:
Name of a mailx command. Most command names can be abbreviated. In “Descriptions in alphabetical order” the accepted abbreviations are shown in bold print. command not specified:
One or more messages to be processed by the command. If several messages are specified, they are separated by blanks. msglist can be one or more of the following:
Message number n
The current message (marked > in the header summary)).
The first undeleted message.
The last message.
All messages.
The next message.
The preceding message.
Messages n through m inclusive.
All messages from the specified user.
All messages with the string str in the subject field (the case is ignored).
All messages of type msgtype, which can be any of the following:
msglist not specified:
String argument as appropriate to the command (see descriptions). If argument is a file name, the usual shell metanotation may be used. If a string containing blanks is to be interpreted as a single argument, it must be enclosed in double quotes. Functional overviewThis section provides an overview of all mailx read-mode commands, grouped by function. Some commands may appear more than once. The overview is followed by descriptions of all the commands in alphabetical order. Help functions
Display summary of mailx commands
Display summary of mailx commands
List names of all mailx commands
Display current message number
Display size of message
Display header summary
Scroll header display one page forward
Scroll header display one page back
Display screen page of headers
Display first five lines of message header
List contents of directory defined by mailx variable folder
Display mailx version number Quitting mailx
Quit mailx without changing mailbox
Quit mailx without changing mailbox
Quit mailx Displaying the header summary
Display header summary
Display screen page of headers
Scroll header display one page forward
Scroll header display one page back Manipulating and displaying the message header
Suppress message header fields
Undo the effect of discard
Suppress message header fields
Undo the effect of ignore
Display only specified fields of message header
Display first five lines of message header Displaying messages
Display message
Display message
Skip to next matching message
Display message with full message header, ignoring discard
Display message with full message header, ignoring discard Editing messages
Call editor to edit message (value of mailx variable EDITOR, default: ed)
Call editor to edit message (value of mailx variable VISUAL, default: vi) Changing the mailbox
Close current mailbox and open named one
Close current mailbox and open named one Saving messages
Hold messages in mailbox
Hold messages in mailbox
Write message to file
Write message to file
Write message to file, omitting header
Write message to user’s standard mailbox
Write message to user’s standard mailbox
Write messages to file named after sender of first message
Write messages to file named after sender of first message Deleting messages
Delete message
Delete message, display next
Delete message, display next Switch to send mode and send or reply to message
Send message
Send message, recording copy in file
Reply to message
Reply to message
Reply to message, recording reply
Reply to list of messages
Reply to list of messages
Reply to list of messages, recording replies Undoing mailx commands during a mailx session
Restore deleted messages
Undo effect of hold
Undo effect of touch
Erase aliases
Undo effect of discard
Undo effect of ignore
Erase variables Invoking command interpreters, running shell commands
Escape to shell
Repeat last shell command
Invoke command interpreter
Pipe messages to standard input of shell command
Pipe messages to standard input of shell command Miscellaneous
Null command (for including comments in command files)
Display current message number
Declare aliases for mail recipients (same as group)
Declare alternate names for your login name
Change directory
Change directory
Echo string (like echo shell command)
List contents of directory defined by mailx variable folder
Declare aliases for mail recipients (same as alias)
construct which selects a command list to execute on the basis of the mode (send, read)
Set variables
Display size of message
Read and execute command file
Erase variables mailx commands not allowed in command files
Escape to shell
Write messages to file named after sender of first message
Call editor to edit message
Reply to message, recording reply
Reply to list of messages, recording replies
Hold messages in mailbox
Send message
Send message, recording copy in file
Hold messages in mailbox
Reply to message
Reply to list of messages
Reply to message
Reply to list of messages
Invoke command interpreter
Call editor to edit message Descriptions in alphabetical orderSome command names have synonyms. The full description is always next to the name which comes first in alphabetical order. Most of these commands can be used both interactively and in command files. Exceptions to this rule are mentioned at the appropriate place (see “Functional overview”). The bold print in the command names refers to the abbreviated forms.
Executes shell_command. By default the command interpreter specified in the mailx variable SHELL will be invoked and the specified command line will be passed to it. If SHELL is not set, /bin/sh will be invoked. If the bang variable is set, the last shell command executed is saved by mailx and can be repeated with !!. The ! command is not permitted in a command file.
This is the null command used to introduce comments in command files (e.g. .mailrc).
Displays the current message number.
Displays a summary of all mailx commands.
Declares an alias for the given recipients. The defined recipients are substituted when you use the aliases as recipients. alias-name: alias-name not specified: recipient not specified: mailx displays the definitions for alias-name.
Declares alternate names for your login name. Once you reply to a message, mailx deletes these alternative names from the list of recipients. name: name not specified:
Changes to the indicated directory. directory not specified:
Copies the specified messages to the named file. If file already exists, it is extended.The messages are marked as read (R) and copied to the user-specific mailbox when the default mailbox is closed. No argument specified: If you do not subsequently delete the message, it will be saved again the next time the default mailbox is closed.
Copies the specified messages to a file in the current directory. The name of this file is derived from the name of the author of the first message in the message list (From entry). If this file already exists, it is extended. The messages are marked as read (R) and copied to the user-specific mailbox when the default mailbox is closed. The Copy command is not permitted in a command file.
Deletes the specified messages from the current mailbox. If the mailx variable autoprint is set, the message following the last deleted message is printed. A deleted message can be restored with undelete during a mailx session.
Suppresses printing of the specified header fields in the output if they appear at the start of a line and come before a colon, e.g.: Cc:, Date:, Status:, Subject:, To:. You do not need to include the colon, and mailx ignores the case of the letters in field. discard has an effect on the mailx commands next, pipe (or |), print, type, ~f and ~m, but not on Print, Type, ~F and ~M. No fields are suppressed when messages are saved. The effect of discard can be undone with undiscard or unignore. retain suppresses the effect of discard: all fields are ignored except those explicitly specified. field not specified:
(delete and print) Deletes messages from the mailbox and displays the message that follows the last one deleted. A deleted message can be restored with undelete during a mailx session.
Echoes string on standard output (like the echo shell command).
Invokes the editor specified with the mailx variable EDITOR (default editor: ed) and loads the specified messages. The edited message will be available in the mailbox again at the end of the editing session. The text is edited in a temporary file named /tmp/Rz$$, where $$ is the process ID of the mailx process (see Files). The edit command is not permitted in a command file.
Exits from mailx without changing the current mailbox, i.e.
Also refer to the mailx command quit.
Quits the current mailbox (like quit) and reads in the specified file as another mailbox. The appropriate header lines are displayed.
Name of the mailbox to be processed, or the following metanotation:
the current mailbox
the default mailbox of the named user (/var/mail/$USER)
the file file in the directory folder (see mailx variable folder)
the previous mailbox
the user-specific mailbox ($HOME/mbox or the mailbox defined by the mailx variable $MBOX) file not specified: file % closes and reopens the current mailbox. This allows you to read any new messages that have arrived during your mailx session.
Lists the names of all files in the directory defined by the mailx variable folder (messages are saved and recorded in this directory by mailx).
Replies to the specified message like the mailx command reply. mailx switches to send mode and considers the recipients to be
When you have completed your input, mailx sends the message. In contrast to reply, followup records the message in a file named after the recipient (with the network path removed). The storage location of this file depends on whether the mailx variables folder and outfolder are set. If both are set, the file is stored in the directory defined by the folder variable. Otherwise it is stored in the current directory. The file is extended if it already exists. The followup command is not permitted in a command file.
Replies to the first of the messages specified in the message list in the same way as the mailx command Reply. mailx switches to send mode and sends the reply to each sender of a message in msglist. When you have completed your input, mailx sends the message. In contrast to reply, Followup records the message in a file named after the sender of the first message (with the network path removed). The storage location of this file depends on whether the mailx variables folder and outfolder are set. If both are set, the file is stored in the directory defined by the folder variable. Otherwise it is stored in the current directory. The file is extended if it already exists. The Followup command is not permitted in a command file.
Prints the header summary for all specified messages on the standard output.
Declares aliases for the given recipients (see alias).
Displays the screen page of headers which includes the specified message. A screen page contains 20 lines or the number of lines defined by the screen variable. message not specified:
Displays a summary of the mailx commands (see also ?).
Holds (i.e. preserves) the specified messages in the default mailbox. The messages are marked H in the header and remain in the mailbox, even if they have been read or saved. The effect of hold can be undone with touch (and vice versa). The hold and preserve commands are not permitted in a command file.
if construct which selects a command list to execute on the basis of the specified mode.
mode is the mode (send or read) in which you invoked mailx. It can be:
(send) command_list1 is executed if you invoked mailx in send mode; otherwise, command_list2 is executed.
(read) command_list1 is executed if you invoked mailx in read mode; otherwise, command_list2 is executed.
Lists of mailx commands. Commands which are not permitted in command files are also not permitted here, i.e.: !, edit, followup, Followup, mail, Mail, reply, Reply, respond, Respond, shell and visual. if, else, endif and all the commands in the command lists must each be on a separate line.
Suppresses printing of the specified header fields (see discard on "mailx interactive message processing system (mail extended)").
Lists the names of all available mailx commands on standard output (also refer to help and ?).
Sends a message to recipient. mailx switches to send mode and mails the message as soon as you have finished entering the text. The mail command is not permitted in a command file.
Sends a message to recipient. mailx switches to send mode and mails the message as soon as you have finished entering the text. The Mail command is not permitted in a command file.
Writes the listed messages to the user-specific mailbox when the current mailbox is closed and then deletes them from the current mailbox, even if they have not been read. All such messages are marked M in the header summary. The user-specific mailbox is $HOME/mbox or the file defined by the mailx variable MBOX.
Goes to the next message containing message in the header summary. For message you can enter characteristics as for a message list. If, for example, the next message you want to read is that of a particular sender, specify next sender. message not specified: mailx displays the message following the current one. next otherwise works in the same way as print.
Pipes the specified messages to the standard input of the given shell_command. No argument specified:
Preserves the specified messages in the default mailbox (see hold).
Prints the specified messages on the standard output. The messages are marked as read (R) in the header summary. They are copied to the user-specific mailbox upon termination of the default mailbox and then deleted from the current one. The user-specific mailbox is $HOME/mbox or the file defined by the mailx variable MBOX.
Like print, except that the whole header is always displayed, i.e. Print overrides the effect of discard and ignore.
Exits from mailx, closing the currently processed mailbox.
Also refer to the mailx commands exit and xit.
Replies to the indicated message. mailx switches to send mode and considers the recipients to be
When you have completed your input, mailx sends the message. Unlike followup, reply does not automatically create a file to record your reply. It only does so if the mailx variable record is set, in which case the message will be written to the file defined there. If the file already exists, it is extended. The reply and respond commands are not permitted in a command file.
Replies to the first message in the message list. mailx switches to send mode and sends the response to the sender of each message in msglist. When you have completed your input, mailx sends the message. Unlike Followup, Reply does not automatically create a file to record your reply. It only does so if the mailx variable record is set, in which case the message will be written to the file defined there. If the file already exists, it is extended. The Reply and Respond commands are not permitted in a command file.
displays only the specified fields of the message header. The other fields are suppressed. retain displays the specified fields as well, if they are contained in the list of fields to suppress, i.e. retain overrides the effects of discard or ignore. field not specified:
Saves the indicated messages in the named file, extending it if it already exists. The messages are marked as saved (S), which means that they are deleted from the default mailbox as soon as you quit mailx, unless you have set the keepsave variable. No argument specified:
Saves the specified messages in a file in the current directory. The file name is derived from the name of the sender of the first message in msglist ("From" entry; network addresses are removed). If the file already exists, it is extended. The messages are marked as saved (S), which means that they are deleted from the default mailbox as soon as you quit mailx, unless you have set the keepsave variable).
Sets the variable name.
Name of a mailx variable or a freely defined variable.
Any string or numeric value. \n within value is interpreted as a newline character, \t as a tab. value not specified: No argument specified: Prints all set variables and their values. The values are enclosed in double quotes. You cannot change the values of environment variables. However, if you define an internal variable of the same name, mailx will use its value until you reset it (this does not apply to the mailx echo command). The tilde command ~i variable can be used to insert the value of variable in the text of a message. You can delete variables with unset.
Invokes by default the command interpreter specified in the SHELL variable. If SHELL is not set, /bin/sh will be invoked. You can specify a different command interpreter with the mailx variable SHELL. The shell command is not permitted in a command file.
Displays the size of the specified messages on standard output in the form message_number: number_of_characters.
Reads the specified file as a command file and executes the mailx commands in it. mailx then returns to the interactive mode (see mailx command and startup files below).
Displays the first 5 lines of the header for each specified message on the standard output. You can change the number of lines displayed with the mailx variable toplines.
Causes the specified messages to be trated as read, i.e. they are copied to the user-specific mailbox upon termination of the default mailbox and then deleted from the current one. The user-specific mailbox is $HOME/mbox or the file defined by the MBOX variable. This does not apply to messages that were saved with save or Save. touch cancels the effect of hold and vice versa.
Prints the specified messages on standard output (see print on "mailx interactive message processing system (mail extended)").
Like print, except that the whole header is always displayed (see Print on "mailx interactive message processing system (mail extended)").
Deletes the specified alias names.
Restores the specified messages provided they were deleted during the current session. The messages are marked as read (R). If the autoprint variable is set, the last restored message is displayed. msglist not specified:
Deletes the specified header fields from the list of fields being ignored. field not specified:
Deletes the specified variables. If you delete a variable with the same name as an environment variable, you can access the value of the corresponding environment variable again.
Displays the current version and release number of mailx.
Invokes the editor specified by the mailx variable VISUAL (default editor: vi) and loads the indicated messages. The edited message is placed in the mailbox at the end of the editing session. The text is processed in a temporary file named /tmp/Re$$, where $$ is the process ID of the mailx process. The visual command is not permitted in a command file.
Writes the specified messages in the named file. If the file already exists, it is extended. write does not copy the header and the trailing blank line. The messages are marked as saved (S) in the header summary. They are deleted from the default mailbox as soon as you quit mailx, unless you have set the keepsave variable.
Exits from mailx without changing the current mailbox (see exit on "mailx interactive message processing system (mail extended)").
Scrolls the header display one page forward (z+) or back (z-). The number of lines per page is set by the screen variable. If screen is not set, 20 lines are displayed by default. +|− not specified: Functionality in read modeAt start-up time, mailx will take the following steps in sequence:
If no mail is present, mailx issues the message:
If mail has been received, mailx responds with a message line, an overview of all messages currently in the mailbox, and the mailx prompt ?. You can now enter mailx commands.You can use the ?, help and list command to get a list of all the available commands. Headers When you call mailx or use one of the mailx commands from, headers or z, mailx displays a header line for each message present. A header can have up to 9 blank-separated fields, e.g.:
These fields refer to:
Processing status (see next subsection)
Message number. The messages are renumbered each time mailx is invoked. The oldest message is numbered 1.
Sender
Date message received
Time message received
Size of message in lines/characters
Title (first 25 characters of subject entry) Processing status The processing status is the entry in the first header field. The status will be one of the following:
(old) The message has been read by a previous mailx call. It will be stored in $HOME/mbox, when you quit mailx or close the default mailbox.
(unread) The message has been present in the system mailbox for more than one invocation of mailx and has not yet been read. It will be preserved in the current mailbox when you quit mailx using quit.
(read) The message has been read. It will be saved in $HOME/mbox, if you quit mailx or the default mailbox.
(new) The message has arrived since you last called mailx or changed mailboxes. Messages in state new when mailx quits will be retained in the system mailbox.
(mbox) The message has been saved with mbox.
(hold) The message has been marked by the hold or preserve command. It will stay in the default mailbox when you close it.
(save) The message has been saved with a save, Save or write. It will be deleted from the default mailbox when you close it.
This is the current message. This is the message referenced by mailx commands if you do leave msglist unspecified. The character c stands for any of the above status characters. User-specific mailbox Messages are written to the user-specific mailbox if
The user-specific mailbox is $HOME/mbox or the file defined by the mailx variable MBOX. The file is extended if it already exists. If you use the -f when you call mailx, you can process this file with mailx commands in exactly the same way as the default mailbox. |
Send mode
No option specified mailx behaves as described in “Functionality in send mode”.
(file) mailx records all outgoing messages in a file named after the first specified recipient. This file is created in your home directory and can be processed with mailx like a mailbox. -F not specified:
mailx ignores the SIGINT signal (see also the mailx variable ignore).
mailx does not initialize from the global startup file /etc/mail/mailx.rc (see "mailx command and startup files" below).
(subject) mailx enters subject in the Subject: header field. of the header summary. This allows you to indicate the subject of the message. subject
One or more recipients. recipient can be:
If recipient begins with a pipe symbol (|), the rest of the name is taken to be a shell command to pipe the message through. mailx commands in send mode (tilde commands)Input format Apart from being preceded by an escape symbol, mailx send-mode commands have the same format as read-mode commands.
Tilde as escape symbol. The mailx variable escape can be used to define a different character as the escape symbol. But the different character must not be a character which describes a command (e.g. ? or !).
As described above under mailx commands in send mode, “Input format”. Functional overviewThis section provides an overview of all mailx send-mode commands, grouped by function. Some commands may appear more than once. Help functions
Display summary of tilde commands
Display message being entered Terminating/aborting text input
Terminate input and send
Abort input and do not send
Abort input and save but do not send Inserting values of variables, old messages and files
Insert value of sign variable
Insert value of Sign variable
Insert value of mailx or environment variable
Insert contents of $HOME/dead.letter
Insert old messages
Insert old messages
Insert old messages
Insert old messages
Insert contents of named file
Insert contents of named file Invoking command interpreters, running shell commands
Escape to shell
Run shell command and insert output in text
Pass text to shell command and replace with command output Displaying text
Display message being entered Editing text
Call editor to edit text (default: ed)
Call editor to edit text (default: vi) Modifying mailing lists
Add names to Bcc list
Add names to Cc list
Add names to To list
Edit To, Subject, Cc and Bcc fields Manipulating the message header
Add names to Cc list
Add names to To list
Edit To, Subject, Cc and Bcc fields
Replace contents of Subject field Recording text
Write message being entered to file, omitting header
Abort input and save text but do not send Send-mode commands which expect mailx to have been called in read mode
Execute mailx command
Execute mailx command
Insert old messages
Insert old messages
Insert old messages
Insert old messages Executing mailx read-mode commands
Execute mailx read-mode command
Execute mailx read-mode command Descriptions in alphabetical ordermailx commands in send mode (tilde commands) must start with an escape symbol in column one. The default escape symbol is a tilde ( ̃), but this can be redefined with the mailx variable escape. Tilde commands are not permitted in a command file. executes the specified shell_command. Invokes by default the command interpreter specified in the SHELL variable. If SHELL is not set, /bin/sh will be invoked. Terminates message input and sends the message. If you are working via rlogin on a remote computer, this tilde command will be interpreted as an instruction to clear down the connection, with the result that the remote session will be terminated immediately. Here are some possible solutions:
Executes the specified mailx read-mode command. You must have invoked mailx in read mode (and then switched to send mode with a mailx command such as mail). Otherwise, mailx will only execute commands that have nothing to do with the processing of a mailbox (e.g. set or exit). The underscore in the second format is mandatory.
Displays a summary of all tilde commands.
(a - autograph) Inserts the value of the mailx variable sign in the message.
(A - autograph) Inserts the value of the mailx variable Sign in the message. This enables you to define an alternate sign-off string, for example.
(b - blind carbon copy) Adds one or more names to the blind carbon copy (Bcc) list. The Bcc list contains the names of additional recipients of the message. These names are not included in the header.
(c - carbon copy) Adds one or more names to the carbon copy (Cc) list. The Cc list contains the names of additional recipients. These names are included as part of the header information (the Cc entry).
(d - dead.letter) Reads the contents of the file $HOME/dead.letter into the message. This file contains messages which mailx could not send or which you aborted with ~q.
(e - editor ed) Invokes the editor specified by the mailx variable EDITOR (default editor: ed) and loads the partial message. Input of the partial message may be continued after the editing session.
(f - file) Inserts the specified messages, without alteration, into the message text. This command is only executed if mailx was invoked in read mode (Format 1).
works like ~f, but inserts always the whole message header. discard, ignore and retain will be ignored.
(h - header) Prompts successively for the following information: To: Recipient Subject: Subject of the message Cc: Carbon copy list containing additional recipients of the message; the names in this list appear in the Cc field of the header Bcc: Blind carbon copy list. Like Cc, except that the names do not appear in the header The fields are displayed with existing values (if any), which you can edit as if you had just entered them.
(i - insert) Inserts the value of the named variable into the message text. The named variable can be a mailx variable or an environment variable.
(m - move) Inserts the indicated messages into the text, shifting each line one tab stop to the right. This command is executed only if mailx was invoked in read mode (Format 1).
works like ~m, but inserts always the whole message header. discard, ignore and retain will be ignored.
(p - print) Displays the message being entered.
(q - quit) Quits input mode by simulating an interrupt. The input text is not aborted but saved in the $HOME/dead.letter file. This tilde command has the same effect as CTRL+C except that it cannot be suppressed with the ignore variable.
(r - read) Inserts the contents of file or the output of shell_command into the message text.
(s - subject) Sets the Subject field of the header to the specified string. Multiple blank-separated strings do not need to be quoted.
(t - to) Adds the indicated names of one or more recipients to the "To" field of the header. Multiple names must be separated by blanks.
(v - editor vi) Invokes the screen editor identified by the mailx variable VISUAL (default editor: vi) and loads the partially entered message. Input of the edited message can be continued on completion of the editing session.
(w - write) Copies the partially entered message, without the header, into the specified file. If the file does not exist, it will be created. Otherwise the message is appended to the specified file.
(x - xit) Exits, aborting the message being entered. The partially entered message is neither sent nor saved.
Pipes the current text of the message to the standard input of shell_command. If the shell command returns an exit status of 0, the current text is replaced by the output of the command. Invokes by default the command interpreter specified in the SHELL variable. If SHELL is not set, /bin/sh will be invoked. Functionality in send modeWhen you call mailx, it first processes startup files. These files may be used to initialize mailx variables, for example (see mailx command and startup files). Then, unless you use the -s option to specify a message subject, mailx displays:
and expects you to enter the subject of the message. This line, which may consist of up to 1024 characters, is written by mailx into the Subject: field of the message header. If the subject is too long, mailx will print the message mailx will now be in send mode, which means that you can enter your message text. All mailx tilde commands are permitted during text input. They must start in column 1. Once you have sent off a tilde command with the enter key, mailx redisplays the whole of the command you have entered in the same line, followed by the string mailx stores the input text in a temporary file in the /tmp directory. The command ~. or CTRL+D signals the end of input. Tilde commands in read mode Some tilde commands only offer their full functionality if you call mailx in read mode (Format 1) and temporarily switch from there to send mode. The commands in question are: ~_ and ~: (execute mailx command) and ~f and ~m (insert old messages). The read commands you can use to switch temporarily to send mode so as to send or reply to a message are followup, Followup, mail, Mail, reply, Reply, respond and Respond. |
mailx command and startup files
Command files Command files are files that contain mailx commands. Each mailx command must be entered in a separate line. You can execute command files by using the source command during a mailx session, or you can use them as startup files (see below). Tilde commands are not permitted in command files, and nor are the commands !, edit, followup, Followup, mail, Mail, reply, Reply, respond, Respond, shell and visual. The copy, Copy, hold and preserve commands are permitted, but then any subsequent commands which are intended to operate on a message list will be ignored. If an error occurs in a command file, mailx ignores all subsequent commands in the file. An error also occurs if a message list refers to a non-existent message (see Example 2). Startup files Startup files are command files that mailx processes every time it is invoked, unless you call it in read mode using the -e or -n options. mailx first processes the global startup file /etc/mail/mail.rc, followed by the private startup file $HOME/.mailrc, provided such files exist. You can redefine the path name of the private startup file with the MAILRC variable. The mailx commands in the startup files may not use msglist, because this information is not yet provided when executing the startup files. |
Variables
mailx utilizes environment variables, mailx variables and freely defined variables. All variables can be imported, and during a mailx session they can be set and reassigned with the set command and deleted with unset. mailx variables, i.e. all variables consisting of lowercase letters only, can only be set within mailx (e.g. in startup files). Contents of shell variables with the same names are not inherited by mailx variables. If you use set to reassign an imported variable, the new value applies until you change it again, delete it with unset or end your mailx session. The mailx command echo always references the original value of an imported variable. asksub, header and save are enabled by default. Of the variables which can be assigned values, the following have default values:
The references to Associated commands in the following list relate to the mailx commands particularly affected by the setting or deletion of the variable in question. |
mailx variables
mailx treats all network names ending with matching login names as identical. Addresses in the form ...computer_name!computer_name!login_name are treated as network names. See also the metoo variable. Default value: The variable is not set. append Appends messages saved in the user-specific mailbox ($HOME/mbox by default) to the end of the file. Associated commands: copy, Copy, file, folder, mbox, next, print, Print, type, Type, quit, touch Default value: The variable is not set.
Causes mailx to prompt for the subject when invoked (see also option -s). Associated commands: ~h, ~s Default value: The variable is set.
mailx prompts for the Bcc list after the subject is entered. Associated commands: ~c, ~h Default value: The variable is not set. askcc mailx prompts for the Cc list after the subject is entered. Associated commands: ~c, ~h Default value: The variable is not set.
Displays the next message after the delete command, and the restored message after the undelete command. Default value: The variable is not set.
Causes mailx to remember the last command executed with !shell_command. You can then repeat the command by entering !!. Default value: The variable is not set.
Sets the default command used by pipe and | to the specified shell_command (only used if no command is specified in pipe). Default value: None.
Pipes message output having more than number lines through the command specified by the PAGER variable (PAGER=more by default). Associated commands: dp, dt, next, print, Print, type, Type,~p Default value: The variable is not set.
Enables diagnostics for debugging. If you set this variable, mail will not be delivered. Default value: The variable is not set.
Causes a line consisting solely of a dot in column one to terminate input (instead of the command ~.). Default value: The variable is not set.
Substitutes c for the tilde escape symbol. c may not be a character describing a command (e.g. ? or !) Default value: ~
The effects of the commands reply, respond and Reply, Respond are exchanged. Associated commands: reply, Reply, respond, Respond Default value: The variable is not set.
If both folder and outfolder are set, reply texts with the followup and Followup commands will be recorded in directory, not in the current directory. If directory does not begin with a slash, mailx sets the directory name to $HOME/directory. You can also use the form +filename to reference these record files in any mailx command which accepts file names. mailx will then expand the name by prepending directory. Default value: The variable is not set.
Causes the header summary, the current mailx version string and the number of messages to be displayed when mailx is invoked. Default value: The variable is set.
Preserves read messages in the default mailbox instead of putting them in the user-specific mailbox file (also refer to MBOX Environment Variables on "mailx interactive message processing system (mail extended)"). Associated commands: copy, hold, mbox, next, preserve, print, Print, quit, touch, type, Type Default value: The variable is not set.
Ignores the SIGINT signal during message input. Associated commands: followup, Followup, mail, Mail, reply, Reply, respond, Respond, ~q (CTRL+C) Default value: The variable is not set.
The end-of-file signal (EOF, CTRL+D) is to be ignored during message input (also refer to the dot variable on "mailx interactive message processing system (mail extended)"). Associated commands: followup, Followup, mail, Mail, reply, Reply, respond, Respond, ~. Default value: The variable is not set.
During the insertion of a message into a text each line of the message begins with string. Associated commands: ~m, ~M Default value: Tab character.
The mailbox should not be deleted when it is empty. Default value: The variable is not set. keepsave Messages that are marked as saved (S) in the header are not to be deleted from the default mailbox. Associated commands: save, Save, write Default value: The variable is not set.
If your own login name appears in the list of recipients ("To" list), it is not deleted from the list. See also the mailx command alias and the allnet variable. Associated commands: alias, alternates, followup, group, reply, respond, ~h Default value: The variable is not set.
If both outfolder and folder are set, reply files with the followup and Followup commands will be stored in the directory defined by folder (also refer to record variable on "mailx interactive message processing system (mail extended)"). If only outfolder (or only folder) is set, reply files will be stored in the current directory. Default value: The variable is not set.
Causes a form feed character (FF = CTRL+L = X’0C’) to be inserted after each message routed through a pipe or | command. Default value: The variable is not set.
Sets the input prompt for mailx read-mode commands to string. Default value: ?
Suppresses the display of the opening message and version identifier when mailx is invoked. Default value: The variable is not set.
Records all outgoing mail in the named file. The file is extended if it already exists. Associated commands: mail, Mail, reply, Reply, respond, Respond, ~. Default value: The variable is not set.
Saves messages that could not be sent, e.g. due to an error or an interrupt from CTRL+C during input. These messages are saved in the file specified by the DEAD variable. Associated commands: followup, Followup, mail, Mail, reply, Reply, respond, Respond, ~d, ~q (CTRL+C) Default value: The variable is set.
mailx displays number header lines. Associated commands: header Default value: Dependent on the terminal type specified by TERM, usually 20
After a read command, waits for the background mailer to finish before returning control to the user. Associated commands: followup, Followup, mail, Mail, reply, Reply, respond, Respond Default value: The variable is not set.
If you send a message and include yourself among the recipients, the name of the first recipient in the recipient list (To list) will appear in the header list displayed, not your login name. Associated commands: from, headers, z+, z- Default value: The variable is not set.
Defines an autograph string to be inserted into the text of a message. Associated commands: ~a, ~i Default value: The variable is not set.
Defines an (additional) autograph string to be inserted into the text of a message. Associated commands: ~A, ~i Default value: The variable is not set.
mailx displays number lines from the message header. Associated commands: top Default value: 5 |
Error
mailx’s error messages are largely self-explanatory. |
File
/etc/mail/mail.rc Global startup file $HOME/.mailrc Private startup file /var/mail/$USER The default mailbox that is searched by mailx for incoming messages. $HOME/mbox User-specific mailbox in which mailx saves messages that have been read. $HOME/dead.letter File that is used by mailx to save messages that could not be sent, e.g. due to an error or an interrupt with CTRL+C during input. If the file already exists, it is overwritten. ./<username> Files created in the current directory with names derived from a login name. These files are created by mailx in response to the following commands: You can also select some other directory instead of the current directory (see the mailx variables folder ("mailx interactive message processing system (mail extended)") and outfolder ("mailx interactive message processing system (mail extended)")). /tmp/R[emsxz]* Temporary files. /tmp/Rz$$ Temporary file used by the commands edit, visual, ̃e, and ̃v. $$ is the process ID of the mailx process. /usr/share/lib/mailx/mailx.help* Help message files |
Environment variables
The named file is used by mailx to save messages that could not be sent, e.g. due to an error or an interrupt during input. This file is extended if it already exists. Associated commands: followup, Followup, mail, Mail, reply, Reply, respond, Respond, ~d, ~q (CTRL+C) Default value: $HOME/dead.letter
In a mailx session, message texts can be edited with the editor named as shell_command (also refer to mailx variable VISUAL ("mailx interactive message processing system (mail extended)")). Default value: ed.
Home directory.
Uses shell_command to list files in the folder directory. Associated commands: folders Default value: ls
file defines the name of the private startup file (default: $HOME/.mailrc; see “mailx command and startup files”).
file designates the user-specific mailbox in which mailx is to save read messages before removing them. Each additional message extends the file (also refer to the hold variable on "mailx interactive message processing system (mail extended)"). Associated commands: copy, hold, mbox, next, preserve, print, Print, quit, save, touch, type, Type Default value: $HOME/mbox
Uses the specified shell_command for the paging of output that exceeds the number of lines defined in the crt variable. Associated commands: dp, dt, next, print, Print, type, Type, ̃p Default value: more
shell-kommando legt den Kommando-Interpreter fest, den mailx benutzt, um POSIX-Kommandos auszuführen. Relevante Kommandos: !, shell Standard-Wert: /bin/sh
Contains information about the terminal type. The TERM variable will be evaluated if the mailx variable screen is not set.
The USER variable tells mailx the login name of the user, to enable it to identify the default mailbox etc.
In a mailx session, message texts can be edited with the editor named as shell_command. Associated commands: visual, ~v Default value: vi. |
Locale
The following environment variables affect the execution of mailx: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example 1
Replying to a message User marvin receives the message
<enter key>
|
Example 2
Example of a startup file The following startup file sets variables and prints all messages from winnie (with lp) when mailx is invoked in read mode. # Processing variables set page crt=24 cmd=lp VISUAL set sign="\n\tFord Prefect\n\tSales Division\n\t Detroit" # Sender: Network system administrator alias sys root@orlando root@annapolis root@chicago # Prints specific mail if r pipe winnie lp from winnie endif Note that mailx terminates the script if any command cannot be executed. This might be the case here with the pipe command if no messages from winnie were present. In other words, mailx then would not execute the from command (or any others that might follow). |
See also
ed, ls, more, sh, vi |