mailx(1) mailx(1)NAME mailx - interactive message processing system SYNOPSIS mailx [-d] [-e] [-f [filename]] [-F] [-h number] [-H] [-i] [-n] [-N] [-r address] [-s subject] [-u user] [-U] [name ...] DESCRIPTION mailx provides a flexible environment for sending and re- ceiving messages electronically. When reading mail, mailx provides commands to facilitate saving, deleting, and responding to messages. When sending mail, mailx allows editing, reviewing, and other modifications of the message as it is entered. Incoming mail is stored in a standard file for each user, called the system mailbox for that user, usually named /usr/mail/name. (You may alter this default by using the -f flag option, as shown later.) When mailx is 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 secon- dary file for storage, unless specific action is taken, so that the messages need not be seen again. This secondary file is named mbox and is normally located in the user's home directory (see ENVIRONMENT VARIABLES, later, for a description of this file). Messages remain in this file un- til forcibly removed. On the command line, flag options start with a dash (-) and any other arguments are taken to be destinations (reci- pients). If no recipients are specified, mailx will attempt to read messages from the mailbox. Flag options are: -d Turn on debugging output; neither particular- ly interesting nor recommended. -e Test for presence of mail. mailx prints nothing and exits with a successful return code if there is mail to read. -f [filename] Read messages from filename instead of mail- box. If no filename is specified, mbox is used. -F Record the message in a file named after the first recipient. Overrides the record vari- able, if set (see ENVIRONMENT VARIABLES). -h number The number of network hops made so far. This is provided for network software to avoid in- finite delivery loops. April, 1990 1
mailx(1) mailx(1)-H Print header summary only. -i Ignore interrupts. See also ignore in EN- VIRONMENT VARIABLES. -n Do not initialize from the system default /usr/lib/mailx/mailx.rc. -N Do not print initial header summary. -r address Pass address to network delivery software. All tilde commands are disabled. -s subject Set the Subject header field to subject. -u user Read user's mailbox. This is only effective if user's mailbox is not read-protected. -U Convert uucp style addresses to internet standards. Overrides the conv environment variable. To terminate a mail message, type an end-of-file, or enter a single period at the start of a line. When reading mail, mailx is in command mode. A header sum- mary of the first several messages is displayed, followed by a prompt indicating mailx can accept regular commands (see COMMANDS later in this section). When sending mail, mailx is in input mode. If no subject is specified on the command line, a prompt for the subject is printed. As the message is typed, mailx will read the message and store it in a tem- porary file. Commands may be entered by beginning a line with the escape character (tilde (~) by default) followed by a single command letter and optional arguments. See TILDE ESCAPES later in this section, for a summary of these com- mands. At any time, the behavior of mailx is governed by a set of environment variables. These are flags and valued parame- ters that are set and cleared via the se[t] and uns[et] com- mands. See ENVIRONMENT VARIABLES, later, for a summary of these parameters. Recipients listed on the command line may be of three types: login names, shell commands, or alias groups. Login names may be any network address, including mixed network address- ing. 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 2 April, 1990
mailx(1) mailx(1)are set by the a[lias] command (see COMMANDS, later) and are lists of recipients of any type. Regular commands are of the form: [command] [msglist] [arguments] If no command is specified in command mode, p[rint] is as- sumed. In input mode, commands are recognized by the escape character, and lines not treated as commands are taken as input for the message. Each message is assigned a sequential number, and there is at any time the notion of a ``current'' message, marked by a > in the header summary. Many commands take an optional list of messages (msglist) to operate on, which defaults to the current message. A msglist is a list of message specif- ications separated by spaces, which may include: n Message number n. . The current message. ^ The first undeleted message. $ The last message. * All messages. n-m An inclusive range of message numbers. user All messages from user. /string All messages with string in the subject line (case ignored). :c All messages of type c, where c is one of d deleted messages n new messages o old messages r read messages u unread messages Note that the context of the command determines whether this type of message specification makes sense. Other arguments are usually arbitrary strings whose usage depends on the command involved. Filenames, where expected, are expanded via the normal shell conventions (see csh(1)). Special characters are recognized by certain commands and are documented with the commands later. At startup time, mailx reads commands from a system-wide file (/usr/lib/mailx/mailx.rc) to initialize certain parame- ters, then from a private startup file ($HOME/.mailrc) for personalized variables. Most regular commands are legal in- side startup files, the most common use being to set up ini- tial display options and alias lists. The following com- mands are not legal in the startup file: !, C[opy], e[dit], fo[llowup], F[ollowup], ho[ld], m[ail], pre[serve], r[eply], April, 1990 3
mailx(1) mailx(1)R[eply], sh[ell], and v[isual]. Any errors in the startup file cause the remaining lines in the file to be ignored. COMMANDS The following is a complete list of mailx commands: !shell-command Escape to the shell. See SHELL (ENVIRON- MENT VARIABLES). # comment Null command (comment). This may be use- ful in .mailrc files. = Prints the current message number. ? Prints a summary of commands. a[lias] alias name... g[roup] alias name... Declares an a[lias] or g[roup] for the given names. The names will be substitut- ed when alias is used as a recipient. Useful in the .mailrc file. alt[ernates] name... Declares a list of alternate names for your login. When responding to a message, these names are removed from the list of recipients for the response. With no ar- guments, alt[ernates] prints the current list of alternate names. (See also allnet under ENVIRONMENT VARIABLES.) cd [directory] ch[dir] [directory] Changes directory. If directory is not specified, $HOME is used. c[opy] [filename] c[opy] [msglist] Copies messages to the file without mark- ing the messages as saved. Otherwise equivalent to the s[ave] command. C[opy] [msglist] Saves the specified messages in a file whose name is derived from the author of the message to be saved, without marking the messages as saved. Otherwise equivalent to the S[ave] command. d[elete] [msglist] Deletes messages from the mailbox. If au- toprint is set, the next message after the last one deleted is printed (see ENVIRON- 4 April, 1990
mailx(1) mailx(1)MENT VARIABLES). di[scard] [header-file...] ig[nore] [header-file...] Suppresses printing of (discard or ignore) the specified header fields when display- ing messages on the screen. Examples of header fields to ignore are status and cc. The fields are included when the message is saved. The P[rint] and T[ype] commands override this command. dp [msglist] dt [msglist] Deletes the specified messages from the mailbox and print the next message after the last one deleted. Roughly equivalent to a d[elete] command followed by a p[rint] command. ec[ho] string Echos the given strings (like echo(1)). e[dit] [msglist] Edits the given messages. The messages are placed in a temporary file and the ED- ITOR variable is used to get the name of the editor (see ENVIRONMENT VARIABLES). Default editor is ed(1). ex[it] x[it] Exits from mailx, without changing the mailbox. No messages are saved in the mbox (see also q[uit]). fi[le] [filename] fold[er] [filename] Quits the current file of messages and read in the specified file (folder). Several special characters are recognized when used as filenames, with the following substitutions: % the current mailbox. %user the mailbox for user. # the previous file. & the current mbox. Default file is the current mailbox. folders Prints the names of the files in the directory set by the folder variable (see ENVIRONMENT VARIABLES). fo[llowup] [message] Responds to (follow up on) a message, April, 1990 5
mailx(1) mailx(1)recording the response in a file whose name is derived from the author of the message. Overrides the record variable, if set. See also the F[ollowup], S[ave], and C[opy] commands and outfolder (EN- VIRONMENT VARIABLES). F[ollowup] [msglist] Responds to (Follow up on) the first mes- sage in the msglist, sending the message to the author of each message in the msglist. The subject line is taken from the first message and the response is recorded in a file whose name is derived from the author of the first message. See also the fo[llowup], S[ave], and C[opy] commands and outfolder (ENVIRONMENT VARI- ABLES). f[rom] [msglist] Prints the header summary (``from'' por- tion) for the specified messages. g[roup] alias name... a[lias] alias name... Declare an a[lias] or g[roup] for the given names. The names will be substitut- ed when alias is used as a recipient. Useful in the .mailrc file. h[eaders] [message] Prints the page of headers which includes the message specified. The screen vari- able sets the number of headers per page (see ENVIRONMENT VARIABLES). See also the z command. hel[p] Prints a summary (help list) of commands. ho[ld] [msglist] pre[serve] [msglist] Holds (Preserves) the specified messages in the mailbox. i[f] s|r mail-commands el[se] mail-commands en[dif] Conditional execution, where s will exe- cute following mail-commands, up to an el[se] or en[dif], if the program is in send mode (that is, not receiving or read- ing mail), and r causes the mail-commands 6 April, 1990
mailx(1) mailx(1)to be executed only in receive mode. Use- ful in the .mailrc file. ig[nore] header-file di[scard] header-file Suppresses printing of (ignore or discard) the specified header fields when display- ing messages on the screen. Examples of header fields to ignore are status and cc. All fields are included when the message is saved. The P[rint] and T[ype] commands override this command. l[ist] Prints (lists) all commands available. No explanation is given. m[ail] name Mails a message to the specified users. mb[ox] [msglist] Arranges for the given messages to end up in the standard mbox save file when mailx terminates normally. See mbox (ENVIRON- MENT VARIABLES) for a description of this file. See also the ex[it] and q[uit] com- mands. n[ext] [message] Goes to the next message matching message. A msglist 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 specif- ic user, since the name would be taken as a command in the absence of a real com- mand. See the discussion of msglists above for a description of possible mes- sage specifications. pi[pe ][msglist][shell-command] | [msglist][shell-command] Pipes 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 formfeed character is inserted after each message (see ENVIRONMENT VARI- ABLES). pre[serve] [msglist] ho[ld] [msglist] Preserves (Holds) the specified messages in the mailbox. P[rint] [msglist] April, 1990 7
mailx(1) mailx(1)T[ype] [msglist] Prints (Types) the specified messages on the screen, including all header fields. Overrides suppression of fields by the ig[nore] command. p[rint] [msglist] t[ype] [msglist] Prints (types) the specified messages. If crt is set, the messages longer than the number of lines specified by the crt vari- able are paged through the command speci- fied by the PAGER variable. The default command is pg(1) (see ENVIRONMENT VARI- ABLES). q[uit] Exits (Quits) from mailx, storing messages that were read in mbox and unread messages in the mailbox. Messages that have been saved explicitly in a file are deleted. R[eply] [msglist] R[espond] [msglist] Responds to the author of each message in the msglist. The subject line is taken from the first message. If record is set to a filename, the response is saved at the end of that file (see ENVIRONMENT VARIABLES). r[eply] [message] r[espond] [message] Replies to the specified message, includ- ing all other recipients of the message. If record is set to a filename, the response is saved at the end of that file (see ENVIRONMENT VARIABLES). S[ave] [msglist] Saves 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 C[opy], fo[llowup], and F[ollowup] commands and outfolder (ENVIRONMENT VARI- ABLES). s[ave] [filename] s[ave] [msglist] Appends the specified messages to the end of the given file. The file is created if it does not exist. The message is deleted from the mailbox when mailx terminates un- less keepsave is set (see also ENVIRONMENT VARIABLES and the ex[it] and q[uit] com- 8 April, 1990
mailx(1) mailx(1)mands). mbox is the default filename. se[t] se[t] name se[t] name=string se[t] name=number Defines (sets) a variable called name. The variable may be given a null, string, or numeric value. se[t] by itself prints all defined variables and their values. See ENVIRONMENT VARIABLES for detailed descriptions of the mailx variables. sh[ell] Invokes an interactive shell (see also SHELL (ENVIRONMENT VARIABLES)). si[ze] [msglist] Prints the size in characters of the specified messages. so[urce] filename Reads (sources) commands from the given file and return to command mode. to[p] [msglist] Prints the top few lines of the specified messages. If the toplines variable is set, it is taken as the number of lines to print (see ENVIRONMENT VARIABLES). The default is 5. tou[ch] [msglist] Touches the specified messages. If any message in msglist is not specifically saved in a file, it will be placed in the mbox upon normal termination. See ex[it] and q[uit]. T[ype] [msglist] P[rint] [msglist] Prints (types) the specified messages on the screen, including all header fields. Overrides suppression of fields by the ig[nore] command. t[ype] [msglist] p[rint] [msglist] Prints (types) the specified messages. If crt is set, the messages longer than the number of lines specified by the crt vari- able are paged through the command speci- fied by the PAGER variable. The default command is pg(1) (see ENVIRONMENT VARI- ABLES). u[ndelete] [msglist] Restores (undeletes) the specified deleted messages. Will restore only those mes- sages deleted in the current mail session. April, 1990 9
mailx(1) mailx(1)If autoprint is set, the last message of those restored is printed (see ENVIRONMENT VARIABLES). uns[et] name Causes the specified variables to be erased (unset). If the variable was im- ported from the execution environment (i.e., a shell variable) then it cannot be erased. ve[rsion] Prints the current version and release date. v[isual] [msglist] Edits the given messages with a (visual) screen editor. The messages are placed in a temporary file and the VISUAL variable is used to get the name of the editor (see ENVIRONMENT VARIABLES). w[rite] [msglist] Writes the given messages on the specified file, minus the header and trailing blank line. Otherwise equivalent to the s[ave] command. x[it] ex[it] Exits from mailx, without changing the mailbox. No messages are saved in the mbox (see also q[uit]). z[+|-] Scrolls the header display forward or backward one screenful. The number of headers displayed is set by the screen variable (see ENVIRONMENT VARIABLES). TILDE ESCAPES The following commands may be entered only from input mode, by beginning a line with the escape character (tilde (~) by default). See escape under ENVIRONMENT VARIABLES for chang- ing this special character. ~!shell-command Escape to the shell. ~. Simulate end-of-file (terminate message input). ~:mail-command ~_mail-command Perform the command-level request. Valid only when sending a message while reading mail. 10 April, 1990
mailx(1) mailx(1)~? Print a summary of tilde escapes. ~A Insert the autograph string Sign into the message (see ENVIRONMENT VARIABLES). ~a Insert the autograph string sign into the message (see ENVIRONMENT VARIABLES). ~b name ... Add the names to the blind carbon copy (bcc) list. ~c name ... Add the names to the carbon copy (cc) list. ~d Read in the dead.letter file. See DEAD under ENVIRONMENT VARIABLES for a description of this file. ~e Invoke the editor on the partial mes- sage. See also EDITOR under ENVIRONMENT VARIABLES. ~f [msglist] Forward the specified messages. The messages are inserted into the message, without alteration. ~h 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. ~i string Insert the value of the named variable into the text of the message. For exam- ple, ~A is equivalent to ~i Sign. ~m [msglist] Insert the specified messages into the letter, shifting the new text to the right one tab stop. Valid only when sending a message while reading mail. ~p Print the message being entered. ~q 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 (EN- VIRONMENT VARIABLES) for a description of this file. ~r filename ~< filename April, 1990 11
mailx(1) mailx(1)~< ! shell-command Read in the specified file. If the ar- gument begins with an exclamation point (!), the rest of the string is taken as an arbitrary shell command and is exe- cuted, with the standard output inserted into the message. ~s string ... Set the subject line to string. ~t name ... Add the given name to the To list. ~v Invoke a preferred (visual) screen edi- tor on the partial message. See also VISUAL under ENVIRONMENT VARIABLES. ~w filename Write the partial message onto the given file without the header. ~x Exit as with ~q except the message is not saved in the DEAD file. ~| shell-command 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 re- places the message. ENVIRONMENT VARIABLES The following are environment variables taken from the exe- cution environment and cannot be altered within mailx. HOME= directory The user's base of operations. MAILRC= filename The name of the startup file. Default is $HOME/.mailrc. The following variables are internal mailx variables. They may be imported from the execution environment or set via the se[t] command at any time. The uns[et] command may be used to erase variables. allnet All network names whose last component (login name) match are treated as identical. This causes the msglist message specifications to behave simi- larly. Default is noallnet. See also the alt[ernates] command and the metoo variable. append Upon termination, appends messages to the end of mbox file instead of at the top of mbox. Default is noappend (i.e., by default mailx saves messages at the top of mbox on exit). 12 April, 1990
mailx(1) mailx(1)askcc Prompt for the Cc list after message is entered. Default is noaskcc. asksub Prompt for subject if it is not specified on the command line with the -s flag option. Enabled by default. autoprint Enable automatic printing of messages after d[elete] and u[ndelete] commands. Default is noautoprint. bang Enable the special-casing of exclamation points (!) in shell escape command lines, as in vi(1). Default is nobang. cmd=shell-command Set the default command for the pi[pe] command. No default value. conv=conversion Converts uucp addresses to the specified address style. The only valid conversion now is internet, which requires a mail delivery program conforming to the RFC822 standard for electronic mail ad- dressing. Conversion is disabled by default. See also sendmail and the -U flag option. crt=number Pipes messages having more than number lines through the command specified by the value of the PAGER variable (pg(1) by default). Disabled by default. DEAD=filename The name of the file in which to save partial letters in case of untimely interrupt or delivery errors. Default is $HOME/dead.letter. debug Enables verbose diagnostics for debugging. Mes- sages are not delivered. Default is nodebug. dot Takes a period on a line by itself during input from a terminal as end-of-file. Default is nodot. EDITOR=shell-command The command to run when the e[dit] or ~e command is used. Default is ed(1). escape=c Substitute c for the ~ escape character. folder=directory The directory for saving standard mail files. April, 1990 13
mailx(1) mailx(1)User-specified filenames beginning with a plus (+) are expanded by preceding the filename with this directory name to obtain the real filename. If directory does not start with a slash (/), $HOME is prefixed to it. In order to use the plus (+) construct on a mailx command line, folder must be an exported sh environment variable. There is no default for the folder variable. See also out- folder, later. header Enables printing of the header summary when enter- ing mailx. Enabled by default. hold Preserves all messages that are read in the mail- box instead of putting them in the standard mbox save file. Default is nohold. ignore Ignores interrupts while entering messages. Handy for noisy dial-up lines. Default is noignore. ignoreeof Ignores end-of-file during message input. Input must be terminated by a period (.) on a line by itself or by the ~. command. Default is noig- noreeof. See also dot, above. keep When the mailbox is empty, truncate it to zero length instead of removing it. Disabled by de- fault. keepsave Keeps messages that have been saved in other files in the mailbox instead of deleting them. Default is nokeepsave. MBOX=filename The name of the file in which to save messages that have been read. The x[it] command overrides this function, as does saving the message expli- citly in another file. Default is $HOME/mbox. metoo If your login appears as a recipient, do not delete it from the list. Default is nometoo. LISTER=shell-command The command (and flag options) to use when listing the contents of the folder directory. The default is ls(1). onehop When responding to a message that was originally sent to several recipients, the other recipient addresses normally are forced to be relative to the originating author's machine for the response. This flag option disables alteration of the reci- 14 April, 1990
mailx(1) mailx(1)pients' addresses, improving efficiency in a net- work where all machines can send directly to all other machines (i.e., one hop away). outfolder Cause the files used to record outgoing messages to be located in the directory specified by the folder variable, unless the pathname is absolute. Default is nooutfolder. See folder above and the S[ave], C[opy], fo[llowup], and F[ollowup] com- mands. page Used with the pi[pe] command to insert a formfeed after each message sent through the pipe. Default is nopage. PAGER=shell-command The command to use as a filter for paginating out- put. This can also be used to specify the flag options to be used. Default is pg(1). prompt=string Set the command mode prompt to string. Default is ? . quiet Refrain from printing the opening message and ver- sion when entering mailx. Default is noquiet. record=filename Record all outgoing mail in filename. Disabled by default. See also outfolder, above. save Enable saving of messages in dead.letter on inter- rupt or delivery error. See DEAD for a descrip- tion of this file. Enabled by default. screen=number Sets the number of lines in a screenful of headers for the h[eaders] command. sendmail=shell-command Alternate command for delivering messages. De- fault is mail(1). sendwait Wait for background mailer to finish before re- turning. Default is nosendwait. SHELL=shell-command The name of a preferred command interpreter. De- fault is sh(1). showto When displaying the header summary and the message is from you, print the recipient's name instead of April, 1990 15
mailx(1) mailx(1)the author's name. sign=string The variable inserted into the text of a message when the ~a (autograph) command is given. No de- fault (see also ~i (TILDE ESCAPES)). Sign=string The variable inserted into the text of a message when the ~A command is given. No default (see also ~i (TILDE ESCAPES)). toplines=number The number of lines of header to print with the to (top) command. Default is 5. VISUAL=shell-command The name of a preferred screen editor. Default is vi(1). FILES /usr/bin/mailx /usr/lib/mailx $HOME/.mailrc personal startup file $HOME/mbox secondary storage file /usr/mail/* post office directory /usr/lib/mailx/mailx.help* help message files /usr/lib/mailx/mailx.rc global startup file /tmp/R[emqsx]* temporary files SEE ALSO biff(1), csh(1), ksh(1), mail(1), pg(1), sh(1), ls(1), A/UX Essentials . BUGS Where shell-command is shown as valid, arguments are not al- ways allowed. Experimentation is recommended. Internal variables imported from the execution environment cannot be unset (uns[et]). The full internet addressing is not fully supported by mailx. The new standards need some time to settle down. Attempts to send a message having a line consisting only of a . are treated as the end of the message by mail(1) (the standard mail delivery program). 16 April, 1990