heirloom-mailx (1) Linux Manual Page
NAME
mailx – send and receive Internet mail
SYNOPSIS
-
mailx[-BDdEFintv~] [-ssubject ] [-aattachment ] [-ccc-addr ] [-bbcc-addr ] [-rfrom-addr ] [-hhops ] [-Aaccount ] [-Svariable [=value]] to-addr . . .mailx[-BDdeEHiInNRv~] [-Tname ] [-Aaccount ] [-Svariable [=value]]-f[name]mailx[-BDdeEinNRv~] [-Aaccount ] [-Svariable [=value]] [-uuser ]
DESCRIPTION
Mailx is an intelligent mail processing system, which has
mailx command, and offers extensions for MIME, IMAP, POP3, SMTP, and S/MIME. Mailx provides enhanced features for interactive use, such as caching and disconnected operation for IMAP, message threading, scoring, and filtering. It is also usable as a mail batch language, both for sending and receiving mail.
The following options are accepted:
-Aname - Executes an account command (see below) for name after the startup files have been read.
-afile - Attach the given file to the message.
-B- Make standard input and standard output line-buffered.
-baddress - Send blind carbon copies to list. List should be a comma-separated list of names.
-caddress - Send carbon copies to list of users.
-D- Start in disconnected mode; see the description for the disconnected variable option.
-d- Enables debugging messages and disables the actual delivery of messages. Unlike -v, this option is intended for mailx development only.
-e- Just check if mail is present in the system mailbox. If yes, return an exit status of zero, else, a non-zero value.
-E- If an outgoing message does not contain any text in its first or only message part, do not send it but discard it silently, effectively setting the skipemptybody variable at program startup. This is useful for sending messages from scripts started by cron(8).
-f[file]- Read in the contents of the user’s mbox (or the specified file) for processing; when mailx is quit, it writes undeleted messages back to this file. The string file is handled as described for the folder command below.
-F- Save the message to send in a file named after the local part of the first recipient’s address.
-H- Print header summaries for all messages and exit.
-hhops- Invoke sendmail with the specified hop count. This option has no effect when SMTP is used for sending mail.
-i- Ignore tty interrupt signals. This is particularly useful when using mailx on noisy phone lines.
-I- Shows the `Newsgroup:’ or `Article-Id:’ fields in the header summary. Only applicable in combination with -f.
-n- Inhibits reading /etc/nail.rc upon startup. This option should be activated for mailx scripts that are invoked on more than one machine, because the contents of that file may differ between them.
-N- Inhibits the initial display of message headers when reading mail or editing a mail folder.
-qfile - Start the message with the contents of the specified file. May be given in send mode only.
-raddress - Sets the From address. Overrides any from variable specified in environment or startup files. Tilde escapes are disabled. The -r address options are passed to the mail transfer agent unless SMTP is used. This option exists for compatibility only; it is recommended to set the from variable directly instead.
-R- Opens any folders read-only.
-ssubject - Specify subject on command line (only the first argument after the -s flag is used as a subject; be careful to quote subjects containing spaces).
-Svariable [=value]- Sets the internal option variable and, in case of a string option, assigns value to it.
-Tname - Writes the `Message-Id:’ and `Article-Id:’ header fields of each message read in the file name. Implies -I. Compressed files are handled as described for the folder command below.
-t- The message to be sent is expected to contain a message header with `To:’, `Cc:’, or `Bcc:’ fields giving its recipients. Recipients specified on the command line are ignored.
-uuser - Reads the mailbox of the given user name.
-v- Verbose mode. The details of delivery are displayed on the user’s terminal.
-V- Print mailx‘s version and exit.
-~- Enable tilde escapes even if not in interactive mode.
Sending mail
To send a message to one or more people, mailx can be invoked with arguments which are the names of people to whom the mail will be sent. The user is then expected to type in his message, followed by an `control-D’ at the beginning of a line. The section below Replying to or originating mail, describes some features of mailx available to help when composing letters.
Reading mail
In normal usage mailx is given no arguments and checks the user’s mail out of the post office, then prints out a one line header of each message found. The current message is initially the first message (numbered 1) and can be printed using the print command which can be abbreviated `p’). The user can move among the messages much as he moves between lines in ed(1), with the commands `+’ and `-‘ moving backwards and forwards, and simple numbers.
Disposing of mail
After examining a message the user can delete `d’) the message or reply `r’) to it. Deletion causes the mailx program to forget about the message. This is not irreversible; the message can be undeleted `u’) by giving its number, or the mailx session can be aborted by giving the exit `x’) command. Deleted messages will, however, usually disappear never to be seen again.
Specifying messages
Commands such as print and delete can be given a list of message numbers as arguments to apply to a number of messages at once. Thus `delete 1 2‘ deletes messages 1 and 2, while `delete 1-5‘ deletes messages 1 through 5. In sorted or threaded mode (see the sort and thread commands), `delete 1-5‘ deletes the messages that are located between (and including) messages 1 through 5 in the sorted/threaded order, as shown in the header summary. The following special message names exist:
:n- All new messages.
:o- All old messages (any not in state read or new).
:u- All unread messages.
:d- All deleted messages (for the undelete command).
:r- All read messages.
:f- All `flagged’ messages.
:a- All answered messages (cf. the markanswered variable).
:t- All messages marked as draft.
:k- All `killed’ messages.
:j- All messages classified as junk.
.- The current message.
;- The message that was previously the current message.
,- The parent message of the current message, that is the message with the Message-ID given in the `In-Reply-To:’ field or the last entry of the `References:’ field of the current message.
–- The next previous undeleted message, or the next previous deleted message for the undelete command. In sorted/threaded mode, the next previous such message in the sorted/threaded order.
+- The next undeleted message, or the next deleted message for the undelete command. In sorted/threaded mode, the next such message in the sorted/threaded order.
^- The first undeleted message, or the first deleted message for the undelete command. In sorted/threaded mode, the first such message in the sorted/threaded order.
$- The last message. In sorted/threaded mode, the last message in the sorted/threaded order.
&x- In threaded mode, selects the message addressed with x, where x is any other message specification, and all messages from the thread that begins at it. Otherwise, it is identical to x. If x is omitted, the thread beginning with the current message is selected.
*- All messages.
`- All messages that were included in the message list for the previous command.
/string- All messages that contain string in the subject field (case ignored). See also the searchheaders variable. If string is empty, the string from the previous specification of that type is used again.
- address
- All messages from address. By default, this is a case-sensitive search for the complete email address. If the allnet variable is set, only the local part of the addresses is evaluated for the comparison. Otherwise if the showname variable is set, a case-sensitive search for the complete real name of a sender is performed. The IMAP-style
(fromaddress) expression can be used instead if substring matches are desired. (criterion)- All messages that satisfy the given IMAP-style SEARCH criterion. This addressing mode is available with all types of folders; for folders not located on IMAP servers, or for servers unable to execute the SEARCH command, mailx will perform the search locally. Strings must be enclosed by double quotes `"’ in their entirety if they contain white space or parentheses; within the quotes, only backslash `\’ is recognized as an escape character. All string searches are case-insensitive. When the description indicates that the `envelope’ representation of an address field is used, this means that the search string is checked against both a list constructed as
("real name" "source-route" "local-part" "domain-part")for each address, and the addresses without real names from the respective header field. Criteria can be nested using parentheses.
(criterion1 criterion2 … criterionN)- All messages that satisfy all of the given criteria.
(orcriterion1 criterion2)- All messages that satisfy either criterion1 or criterion2, or both. To connect more than two criteria using `or’, (or) specifications have to be nested using additional parentheses, as with `(or a
(or b c))’; `(or a b c)’ means ((a or b) and c). For a simple `or’ operation of independent criteria on the lowest nesting level, it is possible to achieve similar effects by using three separate criteria, as with `(a) (b) (c)’. (notcriterion)- All messages that do not satisfy criterion.
(bccstring)- All messages that contain string in the `envelope’ representation of the Bcc: field.
(ccstring)- All messages that contain string in the `envelope’ representation of the Cc: field.
(fromstring)- All messages that contain string in the `envelope’ representation of the From: field.
(subjectstring)- All messages that contain string in the Subject: field.
(tostring)- All messages that contain string in the `envelope’ representation of the To: field.
(headername string)- All messages that contain string in the specified Name: field.
(bodystring)- All messages that contain string in their body.
(textstring)- All messages that contain string in their header or body.
(largersize)- All messages that are larger than size (in bytes).
(smallersize)- All messages that are smaller than size (in bytes).
(beforedate)- All messages that were received before date; date must be in the form d[d]
–mon–yyyy, where d[d] is the day of the month as one or two digits, mon is the name of the month—one of `Jan’, `Feb’, `Mar’, `Apr’, `May’, `Jun’, `Jul’, `Aug’, `Sep’, `Oct’, `Nov’, or `Dec’, and yyyy is the year as four digits; e.g. "30-Aug-2004".(ondate)- All messages that were received on the specified date.
(sincedate)- All messages that were received since the specified date.
(sentbeforedate)- All messages that were sent on the specified date.
(sentondate)- All messages that were sent on the specified date.
(sentsincedate)- All messages that were sent since the specified date.
()- The same criterion as for the previous search. This specification cannot be used as part of another criterion. If the previous command line contained more than one independent criterion, the last of those criteria is used.
A practical method to read a set of messages is to issue a from command with the search criteria first to check for appropriate messages, and to read each single message then by typing ``‘ repeatedly.
Replying to or originating mail
The reply command can be used to set up a response to a message, sending it back to the person who it was from. Text the user types in then, up to an end-of-file, defines the contents of the message. While the user is composing a message, mailx treats lines beginning with the character `~’ specially. For instance, typing `~m’ (alone on a line) will place a copy of the current message into the response right shifting it by a tabstop (see indentprefix variable, below). Other escapes will set up subject fields, add and delete recipients to the message, attach files to it and allow the user to escape to an editor to revise the message or to a shell to run some commands. (These options are given in the summary below.)
Ending a mail processing session
The user can end a mailx session with the quit (`q’) command. Messages which have been examined go to the user’s mbox file unless they have been deleted in which case they are discarded. Unexamined messages go back to the post office. (See the -f option above).
Personal and systemwide distribution lists
It is also possible to create a personal distribution lists so that, for instance, the user can send mail to `cohorts‘ and have it go to a group of people. Such lists can be defined by placing a line like
alias cohorts bill ozalp jkf mark kridle [at] ucbcory
in the file .mailrc in the user’s home directory. The current list of such aliases can be displayed with the alias command in mailx. System wide distribution lists can be created by editing /etc/aliases, see aliases(5) and sendmail(8); these are kept in a different syntax. In mail the user sends, personal aliases will be expanded in mail sent to others so that they will be able to reply to the recipients. System wide aliases are not expanded when the mail is sent, but any reply returned to the machine will have the system wide alias expanded as all mail goes through sendmail.
Recipient address specifications
When an address is used to name a recipient (in any of To, Cc, or Bcc), names of local mail folders and pipes to external commands can also be specified; the message text is then written to them. The rules are: Any name which starts with a `|‘ character specifies a pipe, the command string following the `|’ is executed and the message is sent to its standard input; any other name which contains a `@‘ character is treated as a mail address; any other name which starts with a `+‘ character specifies a folder name; any other name which contains a `/‘ character but no `!‘ or `%‘ character before also specifies a folder name; what remains is treated as a mail address. Compressed folders are handled as described for the folder command below.
Network mail (Internet / ARPA, UUCP, Berknet)
See mailaddr(7) for a description of network addresses. Mailx has a number of options which can be set in the .mailrc file to alter its behavior; thus `set askcc‘ enables the askcc feature. (These options are summarized below).
MIME types
For any outgoing attachment, mailx tries to determine the content type. It does this by reading MIME type files whose lines have the following syntax:
type/subtype extension [extension . . .]
where type/subtype are strings describing the file contents, and extension is the part of a filename starting after the last dot. Any line not immediately beginning with an ASCII alphabetical character is ignored by mailx. If there is a match with the extension of the file to attach, the given type/subtype pair is used. Otherwise, or if the filename has no extension, the content types text/plain or application/octet-stream are used, the first for text or international text files, the second for any file that contains formatting characters other than newlines and horizontal tabulators.
Character sets
Mailx normally detects the character set of the terminal using the LC_CTYPE locale setting. If the locale cannot be used appropriately, the ttycharset variable should be set to provide an explicit value. When reading messages, their text is converted to the terminal character set if possible. Unprintable characters and illegal byte sequences are detected and replaced by Unicode substitute characters or question marks unless the print-all-chars is set at initialization time.
The character set for outgoing messages is not necessarily the same as the one used on the terminal. If an outgoing text message contains characters not representable in US-ASCII, the character set being used must be declared within its header. Permissible values can be declared using the sendcharsets variable, separated by commas; mailx tries each of the values in order and uses the first appropriate one. If the message contains characters that cannot be represented in any of the given character sets, the message will not be sent, and its text will be saved to the `dead.letter’ file. Messages that contain NUL bytes are not converted.
Outgoing attachments are converted if they are plain text. If the sendcharsets variable contains more than one character set name, the ~@ tilde escape will ask for the character sets for individual attachments if it is invoked without arguments.
Best results are usually achieved when mailx is run in a UTF-8 locale on a UTF-8 capable terminal. In this setup, characters from various countries can be displayed, while it is still possible to use more simple character sets for sending to retain maximum compatibility with older mail clients.
Commands
Each command is typed on a line by itself, and may take arguments following the command word. The command need not be typed in its entirety – the first command which matches the typed prefix is used. For commands which take message lists as arguments, if no message list is given, then the next message forward which satisfies the command’s requirements is used. If there are no messages forward of the current message, the search proceeds backwards, and if there are no good messages at all, mailx types `applicable messages‘ and aborts the command. If the command begins with a # sign, the line is ignored.
The arguments to commands can be quoted, using the following methods:
- •
- An argument can be enclosed between paired double-quotes "" or single-quotes ”; any white space, shell word expansion, or backslash characters within the quotes are treated literally as part of the argument. A double-quote will be treated literally within single-quotes and vice versa. These special properties of the quote marks occur only when they are paired at the beginning and end of the argument.
- •
- A backslash outside of the enclosing quotes is discarded and the following character is treated literally as part of the argument.
- •
- An unquoted backslash at the end of a command line is discarded and the next line continues the command.
Filenames, where expected, are subjected to the following transformations, in sequence:
- •
- If the filename begins with an unquoted plus sign, and the folder variable is defined, the plus sign will be replaced by the value of the folder variable followed by a slash. If the folder variable is unset or is set to null, the filename will be unchanged.
- •
- Shell word expansions are applied to the filename. If more than a single pathname results from this expansion and the command is expecting one file, an error results.
The following commands are provided:
–- Print out the preceding message. If given a numeric argument n, goes to the n’th previous message and prints it.
?- Prints a brief summary of commands.
!- Executes the shell (see sh(1) and csh(1)) command which follows.
|- A synonym for the pipe command.
account- (ac) Creates, selects or lists an email account. An account is formed by a group of commands, primarily of those to set variables. With two arguments, of which the second is a `{‘, the first argument gives an account name, and the following lines create a group of commands for that account until a line containing a single `}’ appears. With one argument, the previously created group of commands for the account name is executed, and a folder command is executed for the system mailbox or inbox of that account. Without arguments, the list of accounts and their contents are printed. As an example,
account myisp { set folder = imaps : // mylogin@imap.myisp.example set record = +Sent set from = "myname [at] myisp.example (My Name)" set smtp = smtp.myisp.example }creates an account named `myisp’ which can later be selected by specifying `account myisp’.
alias- (a) With no arguments, prints out all currently-defined aliases. With one argument, prints out that alias. With more than one argument, creates a new alias or changes an old one.
alternates- (alt) The alternates command is useful if the user has accounts on several machines. It can be used to inform mailx that the listed addresses all belong to the invoking user. When he replies to messages, mailx will not send a copy of the message to any of the addresses listed on the alternates list. If the alternates command is given with no argument, the current set of alternate names is displayed.
answered- (ans) Takes a message list and marks each message as a having been answered. This mark has no technical meaning in the mail system; it just causes messages to be marked in the header summary, and makes them specially addressable.
cache- Only applicable to cached IMAP mailboxes; takes a message list and reads the specified messages into the IMAP cache.
call- Calls a macro (see the define command).
cd- Same as chdir.
certsave- Only applicable to S/MIME signed messages. Takes a message list and a file name and saves the certificates contained within the message signatures to the named file in both human-readable and PEM format. The certificates can later be used to send encrypted messages to the messages’ originators by setting the smime-encrypt-user [at] host variable.
chdir- (ch) Changes the user’s working directory to that specified, if given. If no directory is given, then changes to the user’s login directory.
classify- (cl) Takes a list of messages and examines their contents for characteristics of junk mail using Bayesian filtering. Messages considered to be junk are then marked as such. The junk mail database is not changed.
collapse- (coll) Only applicable to threaded mode. Takes a message list and makes all replies to these messages invisible in header summaries, unless they are in state `new’.
connect- (conn) If operating in disconnected mode on an IMAP mailbox, switch to online mode and connect to the mail server while retaining the mailbox status. See the description of the disconnected variable for more information.
copy- (c) The copy command does the same thing that save does, except that it does not mark the messages it is used on for deletion when the user quits. Compressed files and IMAP mailboxes are handled as described for the folder command.
Copy- (C) Similar to copy, but saves the messages in a file named after the local part of the sender address of the first message.
decrypt- (dec) For unencrypted messages, this command is identical to copy. Encrypted messages are first decrypted, if possible, and then copied.
Decrypt- (Dec) Similar to decrypt, but saves the messages in a file named after the local part of the sender address of the first message.
define- (def) Defines a macro. A macro definition is a sequence of commands in the following form:
definename{command1 command2 ... commandN}Once defined, a macro can be explicitly invoked using the call command, or can be implicitly invoked by setting the folder-hook or folder-hook-fullname variables.
defines- Prints the currently defined macros including their contents.
delete- (d) Takes a list of messages as argument and marks them all as deleted. Deleted messages will not be saved in mbox, nor will they be available for most other commands.
discard- Same as ignore.
disconnect- (disco) If operating in online mode on an IMAP mailbox, switch to disconnected mode while retaining the mailbox status. See the description of the disconnected variable for more information. A list of messages may optionally be given as argument; the respective messages are then read into the cache before the connection is closed. Thus `disco *’ makes the entire current mailbox available for disconnected use.
dpor dt - Deletes the current message and prints the next message. If there is no next message, mailx says `at EOF‘.
draft- Takes a message list and marks each message as a draft. This mark has no technical meaning in the mail system; it just causes messages to be marked in the header summary, and makes them specially addressable.
echo- Echoes its arguments, resolving special names as documented for the folder command. The escape sequences `
‘, `‘, `
