mail(C) 06 January 1993 mail(C) Name mail, mailx - interactive message processing system Syntax mail [ options ] [ name ... ] mailx [ options ] [ name ... ] Description mail provides a flexible environment for sending and receiving messages electronically. For reading mail, mail provides commands to allow sav- ing, deleting, and responding to messages. For sending mail, mail allows editing, reviewing, and other modification of the message as it is entered. Many of the remote features of mail will only work if the UUCP package is installed on your system. Incoming mail is stored in a standard file for each user, called the mailbox for that user. When mail 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 secondary file for storage, unless specific action is taken, so that the messages need not be seen again. This secondary file is called the mbox and is normally located in the user's HOME directory (see MBOX under ``Environment variables''). Messages can be saved in other secondary files named by the user. Messages remain in a secondary file until forcibly removed. The user can access a secondary file by using the -f option of the mail command. Messages in the secondary file can then be read or otherwise processed using the same commands as in the primary mailbox. This gives rise to the notion of a current mailbox. On the command line, options start with a dash (-) and any other argu- ments are taken to be destinations (recipients). If no recipients are specified, mail attempts to read messages from the mailbox. Command-line options are: -e Test for presence of mail. mail prints nothing and exits with a successful return code if there is mail to read. -f[filename] Read messages from filename instead of mailbox. If no filename is specified, the mbox is used. -F Record the message in a file named after the first reci- pient. Overrides the record variable, if set (see ``Environment variables''). -hnumber The number of network ``hops'' made so far. This is pro- vided for network software to avoid infinite delivery loops. (See addsopt under ``Environment variables''.) -H Print header summary only. -i Ignore interrupts. (See ignore under ``Environment variables''.) -n Do not initialize from the system default .mailrc file. -N Do not print initial header summary. -raddress Pass address to network delivery software. All tilde com- mands are disabled. (See addsopt under ``Environment vari- ables''.) -ssubject Set the Subject header field to subject. -uuser Read user's mailbox. This is only effective if user's mailbox is not read protected. -U Convert UUCP style addresses to internet standards. Over- rides the conv environment variable. (See addsopt under ``Environment variables''.) When reading mail, mail is in command mode. A header summary of the first several messages is displayed, followed by a prompt indicating mail can accept standard commands (see Commands below). When sending mail, mail is in input mode. If no subject is specified on the command line, a prompt for the subject is printed. (A subject longer than 1024 charac- ters will cause mail to dump core.) As the message is typed, mail will read the message and store it in a temporary file. Commands may be entered by beginning a line with the tilde (~) escape character followed by a single command letter and optional arguments. See ``Tilde escapes'' for a summary of these commands. At any time, the behavior of mail is governed by a set of environment variables. These are flags and valued parameters which are set and cleared via the set and unset commands. See ``Environment variables'' below 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 addressing. If mail is found to be undeliverable, an attempt is made to return it to the sender's mailbox. If the recipient name begins with a pipe symbol (|), the rest of the name is taken to be a shell command to pipe the message through. This pro- vides an automatic interface with any program that reads the standard input, such as lp(C), for recording outgoing mail on paper. Alias groups are set by the alias command (see Commands below) and are lists of reci- pients of any type. Regular commands are in the format: [ command ] [ msglist ] [ arguments ] If no command is specified in command mode, print is assumed. In input mode, commands are recognized by the tilde 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 right angle bracket (>) in the header summary. Many commands take an optional list of messages (msglist) to operate on. The default for msglist is the current message. A msglist is a list of message identifiers 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. File names, where expected, are expanded via the nor- mal shell conventions (see sh(C)). Special characters are recognized by certain commands and are documented with the commands below. At start-up time, mail tries to execute commands from the optional system-wide file (/usr/lib/mail/mailrc) to initialize certain parameters, then from a private start-up file ($HOME/.mailrc) for personalized vari- ables. With the exceptions noted below, standard commands are legal inside start-up files. The most common use of a start-up file is to set up initial display options and alias lists. The following commands are not legal in the start-up file: !, C (copy), e (edit), fo (forward), F (Forward), ho (hold), m (mail), pre (preserve), r (reply), R (Reply), sh (shell), and v (visual). An error in the start-up file causes the remaining lines in the file to be ignored. The .mailrc file is optional and must be constructed locally. Commands The following is a complete list of mail commands: ! shell-command Execute shell command and return. (See SHELL under ``Environment variables''.) # comment Null command (comment). This may be useful in .mailrc files. = Print the current message number. ? Print a summary of commands. a alias name ... g alias name ... Declare an alias for the given names; declare a group for the given names. The names will be substituted when alias is used as a recipient. Useful in the .mailrc file. alt name ... Alternates. Declare a list of alternate names for your log- in. When responding to a message, these names are removed from the list of recipients for the response. With no arguments, alternates prints the current list of alternate names. (See allnet under ``Environment variables''.) cd [directory] ch [directory] Change directory. (ch is an abbreviation of chdir.) If directory is not specified, $HOME is used. c [filename] c [msglist] filename copy messages to the file without marking the messages as saved. Otherwise equivalent to the s (save) command. C [msglist] Copy the specified messages to 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 Save command. d [msglist] Delete messages from the mailbox. If autoprint is set, the next message after the last one deleted is printed (see ``Environment variables''). di [header-field ...] ig [header-field ...] Discard or Ignore the header field. Suppress printing of the specified header fields when displaying messages on the screen. Examples of header fields to ignore are ``status'' and ``cc''. The fields are included when the message is saved. The Print and Type commands override these com- mands. dp [msglist] dt [msglist] Delete the specified messages from the mailbox and print the next message after the last one deleted. Roughly equivalent to a delete command followed by a print command. ec string ... Echo the given strings (like echo(C)). e [msglist] Edit the given messages. The messages are placed in a temporary file and the EDITOR variable is used to get the name of the editor (see ``Environment variables''). Default editor is ed(C). ex x Exit from mail without changing the mailbox. No messages are saved in the mbox (see also quit). fi [filename] fold [filename] (Abbreviations for file or folder.) Quit from the current file of messages and read in the specified file. Several special characters are recognized when used as file names, 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 Print the names of the files in the directory set by the folder variable (see ``Environment variables''). for [message] name ... Forward the specified message to the specified users, shifting the forwarded text to the right one tab stop. F [message] name ... Forward the specified message to the specified users, with no indentation. f [msglist] (Abbreviation for from.) Prints the header summary for the specified messages. g alias name ... group. See alias. h [+ | - | msglist] headers. Lists the current range of headers. The screen variable sets the number of headers per page (see ``Environment variables''). If a ``+'' argument is given, then the next page is printed, and if a ``-'' argument is given, the previous page is printed. Both ``+'' and ``-'' can take a number to view a particular window. If a mes- sage list is given, it prints the specified headers, disre- garding all windowing. See also the z command. hel (Abbreviation for help.) Prints a summary of commands. ho [msglist] (abbreviation for hold.) Holds the specified messages in the mailbox. i s|r mail-commands el mail-commands en (Abbreviations: i is short for if, el is short for else, and en is short for end.) Conditional execution, where s causes the first mail commands, up to an el (else) or en (endif) to be executed if the program is in send mode, and r causes the mail commands to be executed only in receive mode. The mail-commands after the else are executed if the program is in the opposite mode from the one indicated. Useful in the mailrc file. ig header-field ... ignore. See discard. li (Abbreviation: li is short for list.) Prints all commands available. No explanation is given. l [msglist] (Abbreviation: l is short for lpr.) Print the specified messages on the lineprinter. m name ... Mail a message to the specified users. M name Mail a message to the specified user and record a copy of it in a file named after that user. mb [msglist] (Abbreviation: mb is short for mbox.) Arrange for the given messages to end up in the standard mbox save file when mail terminates normally. See the ex (exit) and q (quit) commands. n [message] Go to 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 specific user, since the name would be taken as a command in the absence of a real command. See the discussion of msglists above for a description of possible message specifications. pi [msglist] [shell-command] | [msglist] [shell-command] Pipe the message through the given shell-command. The mes- sage is treated as if it were read. If no arguments are given, the current message is piped through the command specified by the value of the cmd variable. If the page variable is set, a form feed character is inserted after each message (see ``Environment variables''). pre [msglist] Preserve (hold) the specified messages in the mailbox. P [msglist] T [msglist] Print (or type) the specified messages on the screen, including all header fields. Overrides suppression of fields by the ig(ignore) command. p [msglist] t [msglist] Print (or type) the specified messages. If crt is set, the messages longer than the number of lines specified by the crt variable are paged through the command specified by the PAGER variable. The default command is more(C) (see ``Environment variables''). q (Abbreviation: q is short for quit.) Exit from mail, stor- ing messages that were read in mbox and unread messages in the mailbox. Messages that have been explicitly saved in a file are deleted from the mailbox. R [msglist] Reply (or Respond) to the specified message, including all other recipients of the message. If record is set to a file name, the response is saved at the end of that file (see ``Environment variables''). r [message] (Abbreviation: r is short for reply or respond.) Send a response to the author of each message in the msglist. The subject line is taken from the first message. If record is set to a file name, the response is saved at the end of that file (see ``Environment variables''). S [msglist] Save the specified messages in a file whose name is derived from the author of the first message. The name of the file is taken to be the author's name with all network address- ing stripped off. See also the C (copy) commands and out- folder (see ``Environment variables''). s [filename] s [msglist] filename Save the specified messages in the given file. The file is created if it does not exist. The message is deleted from the mailbox when mail terminates unless keepsave is set (see also ``Environment variables'' and the ex (exit) and q (quit) commands). se se name se name=string se name=number (Abbreviation: se is short for set.) Define a variable called name. The variable may be given a null, string, or numeric value. se by itself prints all defined variables and their values. See ``Environment variables'' for detailed descriptions of the mail variables. sh Invoke an interactive shell (see SHELL under ``Environment variables''). si [msglist] Print the size in characters of the specified messages. so filename (Abbreviation: so is short for source.) Read commands from the given file and return to command mode. to [msglist] Print 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 [msglist] Touch the specified messages. If any message in msglist is not specifically saved in a file, it will be placed in the mbox, or the file specified in the MBOX environment vari- able, upon normal termination. See ex (exit) and q (quit). T [msglist] Type: see Print. t [msglist] type: see print. u [msglist] (Abbreviation: u is short for undelete.) Restore the speci- fied deleted messages. Messages are undeleted in the order they were deleted; that is, the deleted messages are kept in a queue, not a stack. Will only restore messages deleted in the current mail session. If autoprint is set, the last message of those restored is printed (see ``Environment variables''). uns name ... (Abbreviation: uns is short for unset.) Causes the speci- fied variables to be erased. If the variable was imported from the execution environment (that is, a shell variable), then it cannot be erased. ve Prints the current version and release date. v [msglist] (Abbreviation: v is short for visual.) Edit the given mes- sages with a 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 [msglist] filename Write the given messages on the specified file, minus the header and trailing blank line. Otherwise equivalent to the save command. x See e (exit) or q (quit). z [+|-] Scroll the header display forward or backward one full screen. 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 tilde escape character (~). See escape under ``Environ- ment variables'' for information on changing this special character. ~! shell-command Execute the shell command and return. ~. Simulate end of file (terminate message input). ~: command ~ command Perform the command-level request. Valid only when sending a message while reading mail. ~? Print a summary of tilde escapes. ~A Expand the given alias. ~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 ``Environ- ment variables'' for a description of this file.) ~e Invoke the editor on the partial message. (See 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'', ``Bcc'', and ``Return-Receipt-to'' lists. If the field is displayed with an initial value, it may be edited as if you had just typed it. ~i variable Insert the value of the named variable into the text of the message. For example, ~A is equivalent to ~iSign. Environment variables set and exported in the shell are also accessible by ~i. ~M [msglist] Insert the specified messages into the letter, with no indentation. Valid only when sending a message while read- ing mail. ~m [msglist] Insert the specified messages into the letter, shifting the new text to the right one tab stop. Valid only when send- ing 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 under ``Environment vari- ables''.) ~r filename ~~< filename ~~< !shell-command Read in the specified file. If the argument begins with an exclamation point (!), the rest of the string is taken as an arbitrary shell command and is executed, with the stan- dard output inserted into the message. ~s string ... Set the subject line to string. ~t name ... Add the given names to the ``To'' list. ~v Invoke a preferred screen editor 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 dead.letter. ~| 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 replaces the message. Environment variables The following are environment variables taken from the execution environ- ment and are not alterable within mail. HOME=directory The user's base of operations. MAILRC=filename The name of the start-up file. Default is $HOME/.mailrc. The following variables are internal mail variables. They may be imported from the execution environment or set via the se (set) command at any time. The uns (unset) command may be used to erase variables. addsopt Enabled by default. If /bin/mail is not being used as the deliverer, noaddsopt should be specified. (See ``Notes'' below.) allnet All network names whose last component (login name) matches are treated as identical. This causes the msglist message specifications to behave similarly. Default is noallnet. See also the alt (alternates) command and the metoo vari- able. append Upon termination, append messages to the end of the mbox file instead of prepending them. Default is noappend. 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 option. Enabled by default. autoprint Enable automatic printing of messages after d (delete) and u (undelete) commands. Default is noautoprint. bang Enable the special-casing of exclamation points (!) in shell escape command lines as in vi(C). Default is nobang. chron Cause messages to be displayed in chronological order. The default is reverse chronological order (most recent message first). See also mchron below. cmd=shell-command Set the default command for the pi (pipe) command. Not set by default. conv=conversion Convert 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 addressing. Conversion is disabled by default. See also the sendmail variable and the -U command-line option. crt=number Pipe messages having more than number lines through the command specified by the PAGER variable (more(C) by default). Disabled by default. DEAD=filename The name of the file in which to save partial letters in case of untimely interrupt. Default is $HOME/dead.letter. debug Enable verbose diagnostics for debugging. Messages are not delivered. Default is nodebug. dot Take a dot 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 (edit) or ~e command is used. Default is ed(C). escape=c Substitute c for the ``~'' escape character. Takes effect with next message sent. folder=directory The directory for saving standard mail files. User- specified file names beginning with a plus (+) are expanded by preceding the file name with this directory name to obtain the real file name. If directory does not start with a slash (/), $HOME is prepended to it. In order to use the plus (+) construct on a mail command line, folder must be an exported sh environment variable. There is no default for the folder variable. See also outfolder below. header Enable printing of the header summary when entering mail. Enabled by default. hold Preserve all messages that are read in the mailbox instead of putting them in the standard mbox save file. Default is nohold. ignore Ignore interrupts while entering messages. Useful for noisy dial-up lines. Default is noignore. ignoreeof Ignore end-of-file during message input. Input must be terminated by a dot(.) on a line by itself or by the ~.command. Default is noignoreeof. See also the dot vari- able above. keep When the mailbox is empty, truncate it to zero length instead of removing it. Disabled by default. keepsave Keep 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 to save messages which have been read. The x (exit) command overrides this function, as does sav- ing the message explicitly in another file. Default is $HOME/mbox. mchron Cause message headers to be listed in numerical order (most recently received first), but displayed in chronological order. See also chron above. metoo If your login appears as a recipient, do not delete it from the list. Default is nometoo. LISTER=shell-command The command (and options) to use when listing the contents of the folder directory. The default is ls(C). onehop When responding to a message that was originally sent to several recipients, the other recipient addresses are nor- mally forced to be relative to the originating author's ma- chine for the response. This flag disables alteration of the recipients' addresses, improving efficiency in a net- work where all machines can send directly to all other ma- chines (that is, one hop away). outfolder Record outgoing messages in files located in the directory specified by the folder variable unless the pathname is absolute. Default is nooutfolder. See the folder variable above and the S (Save) and C (Copy) commands. page Used with the pi (pipe) command to insert a form feed after each message sent through the pipe. Default is nopage. PAGER=shell-command Use shell-command as a filter for paginating output. This can also be used to specify the options to be used. Default is more(C). For PAGER to function, the crt vari- able (see above) must be set to a non-zero value. prompt=string Set the command mode prompt to string. Default is ``?''. quiet Refrain from printing the opening message and version when entering mail. 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 interrupt or delivery error. See DEAD for a description of this file. Enabled by default. screen=number Set the number of lines in a full screen of headers for the h(headers) command. sendmail=shell-command Alternate command for delivering messages. Default is rmail(ADM). sendwait Wait for background mailer to finish before returning. Default is nosendwait. SHELL=shell-command The name of a preferred command interpreter. Default is sh(C). showto When displaying the header summary and the message from you, print the recipient's name instead of the author's name. sign=string The variable inserted into the text of a message when the ~a(autograph) command is given. Not set by default (see ~i under ``Tilde escapes''). Sign=string The variable inserted into the text of a message when the ~A command is given. Not set by default (see also ~i under ``Tilde escapes''). toplines=number The number of lines of header to print with the to (top) command. Default is 5. visible Make non-printable characters visible. Control characters (with the exception of tab, newline, and form feed) are displayed as ^X, where X corresponds to the key which would be pressed with the <Ctrl> key to obtain the control character. For example, the <Del> character (octal 0177) is displayed as ^?. Non-ASCII characters in the range 0200 to 0237 octal are displayed as M-^X. In this case, X is the control character corresponding to the seven low order bits. For example, octal character 0200 would be displayed as M-^@. Characters with octal values in the ranges 0040 to 0176 and 0240 to 0377 are considered displayable, and are not converted. This variable is set by default. You can disable it by entering the command uns visible at the mail prompt, or by including this command in your .mailrc file. VISUAL=shell-command The name of a preferred screen editor. Default is vi(C). Files $HOME/.mailrc personal start-up file $HOME/mbox secondary storage file /usr/spool/mail post office directory /usr/lib/mail/mail.*help help message files /usr/lib/mail/mailrc optional global start-up file /tmp/R[emqsx]* temporary files See also ls(C), more(C) Notes The -h, -r and -U options can be used only if mail is built with a delivery program other than /bin/mail. Where shell-command is shown as valid, arguments are not always allowed. Experimentation is recommended. Internal variables imported from the execution environment cannot be uns (unset). The full internet addressing is not fully supported by mail. The new standards need some time to become established. A line consisting only of a ``.'' is treated as the end of the message. mailx is a link to the standard mail program; either name may be used. Standards conformance mail is conformant with: AT&T SVID Issue 2; and X/Open Portability Guide, Issue 3, 1989.