Manual browser: Mail(1)
|MAIL(1)||General Commands Manual||MAIL(1)|
NAMEmail, mailx, Mail — send and receive mail
|[-EIinv] [-a file] [-b bcc-addr] [-c cc-addr] [-r rcfile] [-s subject] to-addr ... [- sendmail-flags]|
|[-EIiNnv] [-H[colon-modifier]] -f [name]|
|[-EIiNnv] [-H[colon-modifier]] [-u user]|
DESCRIPTIONmail is an intelligent mail processing system, which has a command syntax reminiscent of ed(1) with lines replaced by messages.
- Attach file to the message.
- Send blind carbon copies to list. List should be a comma-separated list of names.
- Send carbon copies to list of users.
- Don't send messages with an empty body. This is useful for piping errors from cron scripts.
- Read in the contents of your mbox (or the specified file) for processing; when you quit, mail writes undeleted messages back to this file.
Print the header summaries and exit. The optional colon-modifier string must begin with a ‘
:’ and be followed by one or more of the characters described in the Specifying messages section below. E.g., “mail -H:n” will display just new message headers.
- Forces mail to run in interactive mode even when input isn't a terminal. In particular, the ~ special character when sending mail is only active in interactive mode.
- Ignore tty interrupt signals. This is particularly useful when using mail on noisy phone lines.
- Inhibits the initial display of message headers when reading mail or editing a mail folder.
- Inhibits reading /etc/mail.rc upon startup.
- Specify an alternate user rcfile to load. This overrides the value specified in the environment variable MAILRC which in turn overrides the default ~/.mailrc file.
- 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.)
Is equivalent to:
mail -f /var/mail/user
- Verbose mode. The details of delivery are displayed on the user's terminal.
Sending mailTo send a message to one or more people, mail can be invoked with arguments which are the names of people to whom the mail will be sent. You are then expected to type in your message, followed by a ‘
control-D’ at the beginning of a line.
Any flags following the list of recipients, will be passed, together with their arguments, directly to sendmail(1). For example to change your From address to firstname.lastname@example.org you can specify:
mail recipient -f email@example.com
To prevent multiple copies of a message being sent to the same address, duplicate addresses (after alias expansion) are removed from the bcc-addr, cc-addr, and to-addr lists. In addition, addresses on the cc-addr and to-addr lists are removed if they occur on the bcc-addr list and addresses on the cc-addr list are removed if they occur on the to-addr list. If the to-addr list is empty after these deletions, most systems will insert the line “To: undisclosed recipients:;”.
The section below Replying to or originating mail, describes some features of mail available to help you compose your letter.
Reading mailIn normal usage mail is given no arguments and checks your 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). You can move among the messages much as you move between lines in ed(1), with the commands + and - moving backwards and forwards, and simple numbers.
Disposing of mailAfter examining a message you can delete (d) the message or reply (r) to it. Deletion causes the mail program to forget about the message. This is not irreversible; the message can be undeleted (u) by giving its number, or the mail session can be aborted by giving the exit (x) command. Deleted messages will, however, usually disappear never to be seen again.
Specifying messagesMany commands (e.g., delete, from, and print) accept a list of messages as an argument. Messages may be specified by their message number, by a range of messages, or by a pattern string matching certain fields in the header as described below. These message “specs” may be combined by the usual binary boolean operations ‘
|’, and ‘
^’, which denote, respectively, a logical “and”, “or”, and “xor”. Logical expressions may be grouped with parentheses ‘
(’ and ‘
)’ and negated with ‘
!’. If the binary operator is missing between two message specs, it is assumed to be a ‘
|’. This is for simplicity, backwards compatibility, and also to to facilitate using the ‘
|’ symbol to denote a pipe. (See enable-pipes.)
Besides the obvious (base10) message numbers, the characters ‘
+’, and ‘
$’ denote, respectively, the first message, the message before the “dot” (the current message), the “dot” message, the message following the “dot”, and the last message.
A “message range” consists of two message numbers separated by a ‘
-’. A ‘
*’ denotes all messages and is equivalent to ‘
A pattern is a string (not beginning with any of the above special characters). If it does not begin with a ‘
/’, it is compared with the senders address. If it begins with a ‘
/’, and searchheaders is not defined, the remainder of the string is compared with the subject field. (See searchheaders for searching other header fields or the message body.) If regex-search is not defined, then the comparison is a simple case insensitive substring match. (See regex-search for regular expression matches.)
A list of messages may be restricted by a “colon-modifier” string, i.e., a ‘
:’ followed by one or more of the characters:
d deleted e edited m mboxed n new o old p preserved r read s saved t tagged u unread and not new ! invert the meaning of the colon-modifiers
If there are no address specifications other than colon-modifiers, the colon-modifiers apply to all messages. Thus “
from netbsd :n” would display the headers of all new messages with ‘
netbsd’ in the sender's address, while “
from :!r” and “
from :nu” would both display all new and unread messages. Multiple colon-modifiers may be specified and a single ‘
:’ with no letters following indicates the colon-modifier from the preceding command.
from 1 12 3-5
would display the headers from messages 1, 3, 4, 5, and 12.
from anon & ( /foo | /bar )
would display all headers that had ‘
anon’ in the sender's address and either ‘
foo’ or ‘
bar’ in the subject line.
Generally, commands cannot select messages that are not displayed, such as deleted or hidden messages, the exception being the undelete command.
Replying to or originating mailYou can use the reply command to set up a response to a message, sending it back to the person who it was from. Text you then type in, up to an end-of-file, defines the contents of the message. While you are composing a message, mail 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 tab stop (see indentprefix variable, below). Other escapes will set up subject fields, add and delete recipients to the message, and allow you 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 sessionYou can end a mail session with the quit (q) command. Messages which have been examined go to your 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 system wide distribution listsIt is also possible to create a personal distribution lists so that, for instance, you 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@ucbcory
in the file .mailrc in your home directory. The current list of such aliases can be displayed with the alias command in mail. System wide distribution lists can be created by editing /etc/mail/aliases, see aliases(5) and sendmail(1); these are kept in a different syntax. In mail you send, 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(1).
Network mail (ARPA, UUCP, Berknet)See mailaddr(7) for a description of network addresses.
mail 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.)
SUMMARY(Adapted from the “Mail Reference Manual”)
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, mail types “
No applicable messages” and aborts the command.
- Executes the shell (see sh(1) and csh(1)) command which follows.
- Print out the preceding message. If given a numeric argument n, goes to the n'th previous message and prints it.
- With no argument, it displays the current message number. Otherwise, set the current message number to its first argument.
- Prints a brief summary of commands.
- Pipe the current message body through the shell (see sh(1) and csh(1)) command which follows.
- Like detach but also saves MIME parts that don't have a filename associated with them. For the unnamed parts, a filename is suggested containing the message and part numbers, and the subtype.
(H) Specify or show additional header fields. This is intended for adding extra header fields like “Reply-To:” or “X-Organization:” to the header. For example:
Header X-Mailer: NetBSD mail(1) 9.1
would add the “X-Mailer: NetBSD mail(1) 9.1” line to the message header. Without any arguments, the extra header fields are displayed. With only a header name (including the ‘:’), it will delete all extra header fields with that name. Note: Although some syntax checking is done on the header line, care should be taken to ensure that it complies with RFC 2821 and 2822. Also, the extra header lines are not currently displayed by the ~h tilde command when sending mail (use ~:Header to see them).
- (M) Like more but also prints out ignored header fields.
- (Pa) A synonym for More.
- (P) Like print but also prints out ignored header fields. See also print, more, page, type, view, ignore, and retain.
- (R) Reply to originator. Does not reply to other recipients of the original message. (See reply.)
- (S) Same as save except that all header fields are saved ignoring the saveignore or saveretain lists.
- (T) Identical to the Print command.
- (V) Like Print but has the opposite MIME decoding behavior. (See the mime-decode-message variable.)
- (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.
- (alt) The alternates command is useful if you have accounts on several machines. It can be used to inform mail that the listed addresses are really you. When you reply to messages, mail 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 alternative names is displayed.
Takes a list of messages and prompts for an address to bounce the messages to. If no message is specified, the current message is used. All the original header fields are preserved except for the ‘
X-Original-To’ and ‘
Status’ fields. The new ‘
To’ field contains the bounce address(es) plus any addresses in the old ‘
To’ field minus the user's local address and any on the alternates list. (See the alternates command.)
- (c) Changes the user's working directory to that specified, if given. If no directory is given, then changes to the user's login directory.
- (co) 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 you quit.
Delete duplicate messages based on their ‘
Message-Id’ field, keeping the first one in the current sort order. This can be useful with replies to a mailing list that are also CCed to a subscriber. (The same thing can also be accomplished with the threading and tagging commands.)
- (d) Takes a list of messages as an argument and marks them all as deleted. Deleted messages will not be saved in mbox, nor will they be available for most other commands.
Takes a message list followed by a target directory as arguments, decodes each MIME part in the message list, and saves it in the target directory. If the message list is empty, use the current message. If the directory is not specified, use the directory specified by mime-detach-dir variable and, if that is empty, default to the directory mail was started in. For each MIME part in the message list, the filename is displayed for confirmation or changes. If an empty name is entered, the part is skipped. If the filename already exists, the user will be prompted before overwriting it. (See the mime-detach-batch and mime-detach-overwrite variables to change this behavior.) Only MIME parts with an associated filename in the ‘
Content-Type’ or ‘
Content-Disposition’ fields are decoded. (See Detach to detach all parts.) The MIME extension hooks and character set conversion are ignored.
(also dt) Deletes the current message and prints the next message. If there is no next message, mail says “
- Go down one level in the thread. If given a message number, it descends the thread below that message, otherwise it descends from the current message (dot).
- (e) Takes a list of messages and points the text editor at each one in turn. On return from the editor, the message is read back in.
- Switch the command execution condition set by the previous if, ifdef, or ifndef command.
- Terminate an if, ifdef, or ifndef command.
- (ex or x) Effects an immediate return to the Shell without modifying the user's system mailbox, his mbox file, or his edit file in -f.
- If unset (the default), recipient addresses must be names of local mailboxes or Internet mail addresses. If set, shell expansion of existing mailbox names will be performed.
Expose the thread structure so all messages appear in header listings. (See hide for the inverse.) The default header prompt will indent each header line one space for each level in the threading. The “
%?* ?” format string does this.
- (fi) The same as folder.
- For each message number in the argument list, or the current thread if no message list is given, promote all exposed children to the same thread level.
- List the names of the folders in your folder directory.
(fo) The folder command switches to a new mail file or folder. With no arguments, it tells you which file you are currently reading. If you give it an argument, it will write out changes (such as deletions) you have made in the current file and read in the new file. Some special conventions are recognized for the name. ‘
#’ means the previous file, ‘
%’ means your system mailbox, ‘
%user’ means user's system mailbox, ‘
&’ means your mbox file, and ‘
+file’ means a file in your folder directory.
Takes a list of messages and prompts for an address (or addresses) to forward each message to. If no message list is specified, the current message is used. The mail editor is run for each message allowing the user to enter a message that will precede the forward message. The message is sent as a multipart/mixed MIME encoded message. All header fields except the ‘
Status’ field are included.
- (f) Takes a list of messages and prints their message headers.
(h) Lists the current range of headers, which is an 18-message group. If a ‘
+’ argument is given, then the next 18-message group is printed, and if a ‘
-’ argument is given, the previous 18-message group is printed.
- A synonym for ?
- Collapse the threads so that only the head of each thread is shown, hiding the subthreads. (See expose for the inverse.)
- Restrict the display to untagged messages. In threaded mode, subthreads that connect directly to an untagged message are also displayed, including tagged messages in the connecting chain.
- The same as hide.
- (ho, also preserve) Takes a message list and marks each message therein to be saved in the user's system mailbox instead of in mbox. Does not override the delete command.
Execute commands that follow depending on the operating mode. The current supported modes are ‘
sending’, and ‘
headersonly’. For example, one use might be something like:
if headersonly set header-format="%P%Q%3i %-21.20f %m/%d %R %3K \"%q\"" else set header-format="%P%Q%?& ?%3i %-21.20f %a %b %e %R %3K/%-5O \"%q\"" endif
- Execute commands that follow if the specified variable is defined. Note: This includes environment variables.
- Execute commands that follow if the specified variable is not defined.
- Add the list of header fields named to the ignored list. Header fields in the ignore list are not printed on your terminal when you print a message. This command is very handy for suppression of certain machine-generated header fields. The Type and Print commands can be used to print a message in its entirety, including ignored fields. If ignore is executed with no arguments, it lists the current set of ignored fields.
- Incorporate any new messages that have arrived while mail is being read. The new messages are added to the end of the message list, and the current message is reset to be the first new mail message. This does not renumber the existing message list, nor does it cause any changes made so far to be saved.
- Invert the tags on a list of messages or the current message if none are given. Note: this will not affect any currently deleted messages.
- (m) Takes as argument login names and distribution group names and sends mail to those people.
- Indicate that a list of messages be sent to mbox in your home directory when you quit. This is the default action for messages if you do not have the hold option set.
- (mk) Takes a message list and marks each message as having been read.
- (mo) Takes a message list and invokes the pager on that list.
- (n, like + or CR) Goes to the next message in sequence and types it. With an argument list, types the next matching message.
- (pa) A synonym for more.
- (pre) A synonym for hold.
- (p) Takes a message list and types out each message on the user's terminal.
(q) Terminates the session, saving all undeleted, unsaved messages in the user's mbox file in his login directory, preserving all messages marked with hold or preserve or never referenced in his system mailbox, and removing all other messages from his system mailbox. If new mail has arrived during the session, the message “
You have new mail” is given. If given while editing a mailbox file with the -f flag, then the edit file is rewritten. A return to the Shell is effected, unless the rewrite of edit file fails, in which case the user can escape with the exit command.
- (r) Takes a message list and sends mail to the sender and all recipients of the specified message. The default message must not be deleted. (See the Reply command and the Replyall variable.)
- A synonym for reply.
- Add the list of header fields named to the retained list. Only the header fields in the retained list are shown on your terminal when you print a message. All other header fields are suppressed. The Type and Print commands can be used to print a message in its entirety. If retain is executed with no arguments, it lists the current set of retained fields. Retain overrides save.
Reverse the order of the messages in at the current thread level. This is completely equivalent to “
- (s) Takes a message list and a filename and appends each message in turn to the end of the file. The filename in quotes, followed by the line count and character count is echoed on the user's terminal.
(se) With no arguments, prints all variable values. Otherwise, sets option. Arguments are of the form option=value (no space before or after =) or option. Quotation marks may be placed around any part of the assignment statement to quote blanks or tabs, i.e. “
set indentprefix="->"” Inside single quotes everything is parsed literally, including ‘\’ escaped characters. Inside double quotes ‘\’ character escapes are interpreted. This is an extension as POSIX specifies that ‘\’ should be left uninterpreted for both single and double quoted strings.
- Saveignore is to save what ignore is to print and type. Header fields thus marked are filtered out when saving a message by save or when automatically saving to mbox.
- Saveretain is to save what retain is to print and type. Header fields thus marked are the only ones saved with a message when saving by save or when automatically saving to mbox. Saveretain overrides saveignore.
- (sh) Invokes an interactive version of the shell.
- (sho) Takes a list of variables and prints out their values in the form option=value. If the list is empty, all variable values are shown.
- Display all current messages, tagged or not, unless they are in a hidden thread.
- The same as expose.
- Takes a message list and prints out the size in characters of each message.
Takes an “address-spec” followed by the sendmail flags that should be used when sending mail to an address that matches that “address-spec”. If no sendmail flags are specified, then list the sendmail flags in effect for the “address-spec”. If the “address-spec” is also omitted, then list all smopts settings. The “address-spec” may be an alias, address, domain (beginning with a ‘
@’), or subdomain (beginning with a ‘
.’). If mail is sent to multiple users, the sendmail flags are used only if the flags are the same for each recipients. If smopts-verify is set, then you will be asked to verify the sendmail flags (if there are any) before the mail is sent. Address matching is case insensitive and done from most specific to least.
For example if you have:
smopts mylist -F "List Maintainer" smopts @NetBSD.org -f firstname.lastname@example.org -F "Anon Ymous" smopts friend@NetBSD.org ""
then mail sent to any of the addresses that the ‘
mylist’ alias expands to would have the sender's name set to ‘
List Maintainer’. Mail sent to anyone at NetBSD.org other than ‘
friend@NetBSD.org’ would look like it was sent from ‘
email@example.com’ by ‘
Anon Ymous’. Mail sent to ‘
friend@NetBSD.org’ would not have any sendmail flags set (unless they are set by the ~h escape).
With no argument, sort does nothing. Otherwise it will sort based on the header field name given as an argument. A few names are special:
blines sort based on the number of body lines. hlines sort on the number of header lines. tlines sort on the total number of lines. size sort on the message size sday sent day (ignores the hour/min/sec) rday received day (ignores the hour/min/sec) sdate sent date rdate received date subject sort on the subject, ignoring "Re:" prefixes. from sort on the sender's address.
The check for these special names is case sensitive while the header field name comparisons are case insensitive, so changing the case on any of these special names will sort based on the header field ignoring the special keyword.
There are also three modifiers which may precede the argument:
! reverse the sorting order. ^ case insensitive sorting. - skin the field (removing RFC 822 comments and keep the address).
The same keywords and modifiers also apply to threading. (See the thread command.)
Note: sort has no effect on the threading, sorting only on the heads of the threads if threads exist.
- The source command reads commands from a file.
- Tag a list of messages or the current message if none are given. In hidden thread mode, the entire thread will be tagged, i.e., tag is recursive
- Tag all messages of the current thread below the level of the current message (dot) or the supplied message number if given.
By default this threads the current message list based on the ‘
In-Reply-To’ and ‘
References’ header fields (intended for this purpose by RFC 2822). If given an argument, it will thread on that header field name instead. The same field keywords and modifiers recognized by the sort command are also recognized here. Display of the threads is controlled by the hide and expose commands; navigation of threads is done with the down, up, and tset commands.
If recursive-commands is defined, many commands (e.g., print) act on the entire thread (when it is hidden), otherwise they act on just the current message.
Note: the ‘
In-Reply-To’ and ‘
Reference’ header fields are necessary to do threading correctly. This version of mail now emits these header fields when replying.
- Takes a message list and prints the top few lines of each. The number of lines printed is controlled by the variable toplines and defaults to five.
- Set the current thread (thread set) so that the supplied message number (or the current message if no argument is given) is at the top level of the current thread.
- (t) A synonym for print.
- Takes a list of names defined by alias commands and discards the remembered groups of users. The group names no longer have any significance.
- (u) Takes a message list and marks each message as not being deleted.
- (unr) Takes a message list and marks each message as not having been read.
- Takes a list of option names and discards their remembered values; the inverse of set.
- Takes a list of “address-specs” defined by smopts commands and discards them from the smopts database.
- Untag a list of messages or the current message if none are given. Like the tag command, untag is recursive on hidden threads.
- Undo all threading and sorting, restoring the original display order, i.e., the order in the mail file.
- Go up one level in the thread. This also takes an optional (positive) argument to go up multiple levels in the thread.
- (vie) Like print but has the opposite MIME decoding behavior. (See the mime-decode-message variable.)
- (v) Takes a message list and invokes the display editor on each message.
- (w) Similar to save, except that only the message body (without the header) is saved. Extremely useful for such tasks as sending and receiving source program text over the message system.
- (x) A synonym for exit.
- mail presents message headers in windowfuls as described under the headers command. You can move mail's attention forward to the next window with the z command. Also, you can move to the previous window by using z-.
Tilde/EscapesHere is a summary of the tilde escapes, which are used when composing messages to perform special functions. Tilde escapes are only recognized at the beginning of lines. The name “tilde escape” is somewhat of a misnomer since the actual escape character can be set by the option escape.
- Execute the indicated shell command, then return to the message.
- ~@ [filelist]
- Add the files in the white-space delimited filelist to the attachment list. If filelist is omitted, edit the attachment list, possibly appending to it: For each file in the list the user is prompted to change its attachment data. Changing the filename to empty will delete it from the list. Upon reaching the end of the attachment list, the user is prompted for additional files to attach until an empty filename is given. Filenames containing white-space can only be added in this “edit” mode.
- Inserts the autograph string from the sign= option into the message.
- Inserts the autograph string from the Sign= option into the message.
- ~bname ...
- Add the given names to the list of carbon copy recipients but do not make the names visible in the Cc: line (“blind” carbon copy).
- ~cname ...
- Add the given names to the list of carbon copy recipients.
- Read the file “dead.letter” from your home directory into the message.
- Invoke the text editor on the message collected so far. After the editing session is finished, you may continue appending text to the message.
- Read the named messages into the message being sent. If no messages are specified, read in the current message. Message headers currently being ignored (by the ignore or retain command) are not included.
- Identical to ~f, except all message headers are included.
Edit the message header fields, and the options passed to sendmail (the
Smopts), by typing each one in turn and allowing the user to append text to the end or modify the field by using the current terminal erase and kill characters. If editline(3) support is included, then that line editor is used.
- Inserts the value of the named option into the text of the message.
- Read the named messages into the message being sent, indented by a tab or by the value of indentprefix. If no messages are specified, read the current message. Message headers currently being ignored (by the ignore or retain command) are not included.
- Identical to ~m, except all message headers are included.
- Print out the message collected so far, prefaced by the message header fields.
- Abort the message being sent, copying the message to “dead.letter” in your home directory if save is set.
- Exits as with ~q, except the message is not saved in “dead.letter”.
Reads the named file into the message. If the argument begins with ‘
!’, the rest of the string is taken as an arbitrary system command and is executed, with the standard output inserted into the message.
- Cause the named string to become the current subject field.
- ~tname ...
- Add the given names to the direct recipient list.
- Invoke an alternative editor (defined by the VISUAL option) on the message collected so far. Usually, the alternative editor will be a screen editor. After you quit the editor, you may resume appending text to the end of your message.
- Write the message onto the named file.
- Pipe the message body through the command as a filter. If the command gives no output or terminates abnormally, retain the original text of the message. The command fmt(1) is often used as command to rejustify the message.
- Execute the given mail command. Not all commands, however, are allowed.
- Insert the string of text in the message prefaced by a single ~. If you have changed the escape character, then you should double that character in order to send it.
Mail OptionsOptions are controlled via set and unset commands. Options may be either binary, in which case it is only significant to see whether they are set or not; or string, in which case the actual value is of interest. The binary options include the following:
- Causes messages saved in mbox to be appended to the end rather than prepended. This should always be set (perhaps in /etc/mail.rc).
- ask, asksub
- Causes mail to prompt you for the subject of each message you send. If you respond with simply a newline, no subject field will be sent.
- Causes you to be prompted for additional carbon copy recipients at the end of each message. Responding with a newline indicates your satisfaction with the current list.
- Causes new mail to be automatically incorporated when it arrives. Setting this is similar to issuing the inc command at each prompt, except that the current message is not reset when new mail arrives.
- Causes you to be prompted for additional blind carbon copy recipients at the end of each message. Responding with a newline indicates your satisfaction with the current list.
- Causes the delete command to behave like dp - thus, after deleting a message, the next one will be typed automatically.
- If crt is set, then the PAGER will be used for the print, Print, type, and Type commands. Normally these commands do not invoke the pager. (See page-also.)
- Setting the binary option debug is the same as specifying -d on the command line and causes mail to output all sorts of information useful for debugging mail.
- The binary option dot causes mail to interpret a period alone on a line as the terminator of a message you are sending.
If defined, the output of most commands can be piped into a shell command or redirected to a file. The pipe/redirection is signaled by the first occurrence of a ‘
|’ or ‘
>’ character that is not in a quoted string or in a parenthetical group. This character terminates the mail command line and the remaining string is passed to the shell. For example, assuming normal headers, something like
from john@ | fgrep -i ' "Re:' | wc
could be used to count how may replies were made by senders with ‘
john@’ in their address and
from john@ >> /tmp/john
would append all the headers from such senders to /tmp/john.
Note: With piping enabled, you cannot use the ‘
|’ as a logical “or” operator outside of a parenthetical group. This should not be a problem as it is the default logical operator. (See the Specifying messages section.)
- This option is used to hold messages in the system mailbox by default.
- Causes interrupt signals from your terminal to be ignored and echoed as @'s.
- Usually, when a group is expanded that contains the sender, the sender is removed from the expansion. Setting this option causes the sender to be included in the group.
- If set, the command line flag -a will accept a whitespace delimited list of files. Otherwise, its argument is interpreted as a single filename. Warning: If enabled, care must be taken to properly quote files that contain whitespace, both from the shell and from this second expansion done by mail.
- If set, decode the headers along with the body when mime-decode-message is set. The header decode follows the same rules as the body (see mime-decode-message).
- When inserting a message into the mail buffer (~f or ~F), the text inserted will be decoded according to the settings of the mime-decode-message and mime-decode-header variables.
- If set, the More, more, Page, page, Print, print, Type, and type commands will display decoded the MIME messages. Otherwise, they display the undecoded message. Recall that the View and view commands always have the opposite MIME decoding behavior from these commands.
- When quoting a message into the mail buffer (~m or ~M), the text inserted will be decoded according to the settings of the mime-decode-message and mime-decode-header variables.
If set, the detach command does not prompt for anything (unless mime-detach-overwrite is set to ‘
ask’), overwriting target files depending on the setting of mime-detach-overwrite.
- Setting the option noheader is the same as giving the -N flag on the command line.
- Normally, when you abort a message with two RUBOUT (erase or delete) mail copies the partial letter to the file “dead.letter” in your home directory. Setting the binary option nosave prevents this.
- A comma or whitespace delimited list of additional commands to page. The comparisons are case insensitive, so if view is in the list, both view and View will page.
- If set, disable the pager on all commands.
- Suppresses the printing of the version when first invoked.
When defined, and threading is in effect, the following commands operate on the entire thread (if it is “hidden”) rather than just the top displayed message of the thread:
More Page Print Type View more page print type view top Save copy save write Detach detach delete dp dt undelete hold preserve mbox mkread touch unread tag untag invtags
If not defined, or if the threads are “exposed”, commands behave exactly as they do in non-threaded mode, i.e., each operates on individual messages.
- Reverses the sense of reply and Reply commands.
If this option is set, then a message-list specifier in the form “/x:y” will expand to all messages containing the substring “y” in the header field “x”. The string search is case insensitive. If “x” is omitted, it will default to the ‘
Subject’ header field. If “y” is omitted, only those messages that contain the field “x” will be matched. The three forms “/from:y”, “/to:y”, and “/body:y” are special. The first will match all messages which contain the substring “y” in the headline (which is added locally at receipt time and begins with “From ”). The second will match all messages containing the substring “y” in the ‘
Cc’, or ‘
Bcc’ header fields. The third will match all messages which contain the substring “y” in a line of the message body. The check for “from”, “to”, and “body” is case sensitive, so that “/From:y” and “/To:y” can be used to search the ‘
From’ and ‘
To’ fields, respectively. (See also regex-search.)
- Verify the sendmail options used on outgoing mail if they were obtained from a smopts match. This has no effect if there are no sendmail flags or if the flags were set by the ~h escape.
- Setting the option verbose is the same as using the -v flag on the command line. When mail runs in verbose mode, the actual delivery of messages is displayed on the user's terminal.
Option String Values
- Pathname of the text editor to use in the edit command and ~e escape. If not defined, then a default editor is used.
- Pathname of the directory lister to use in the folders command. Default is /bin/ls.
- Pathname of the program to use in the more command or when crt variable is set. The default paginator more(1) is used if this option is not defined.
- Pathname of the shell to use in the ! command and the ~! escape. A default shell is used if this option is not defined.
- Pathname of the text editor to use in the visual command and ~v escape.
- A comma or space delimited list of keys to do editline(3) completion. For example set el-completion-keys=^I,^D will bind completion to both the tab and CTRL-D keys. (Requires editline(3) support.)
The line editing mode: must be ‘
emacs’ or ‘
vi’. If unset, editing is not enabled. (Requires editline(3) support.)
- The number of lines of history to remember. If unset, history is not enable. (Requires editline(3) support.)
- If defined, the first character of this option gives the character to use in the place of ~ to denote escapes.
The name of the directory to use for storing folders of messages. If this name begins with a ‘
/’, mail considers it to be an absolute pathname; otherwise, the folder directory is found relative to your home directory.
If set, use this format string when displaying headers in command mode. The format string supports the following conversions in addition to those of strftime(3):
The header field with name ‘
key’. Note: if key is ‘
-’, ignore the ‘
-’ and extract the address portion of the field (i.e., “skin” the field).
If the depth is n, substitute ‘
string’ n times. This is intended to be used when displaying an “exposed thread”.
- Like %?*string?, but uses the depth relative to the current depth rather than the absolute depth.
- The number of header lines in the message.
- The number of body lines in the message.
- The total number of lines in the message.
The sender's full name (as in the ‘
From’ or ‘
- The message size.
- The current “dot” (‘>’) message.
- The message status flag.
- The time zone name (if it exists).
- The email address of sender.
- The message number.
- The sender's login name (taken from the address).
- The subject.
- The total number of messages.
- The GMT offset (if found).
If the format string begins with ‘
%??’ then the date will be extracted from the headline. Otherwise it will be extracted from the ‘
Date’ header falling back to the headline if that extraction fails. For example, the default format is:
set header-format="%??%P%Q%?* ?%3i %-21.20f %a %b %e %R %3K/%-5O \"%q\""
Note 1: The message status flag ‘
%Q’ will display the single character ‘
+’ for the parent of a subthread. This will be overwritten by a ‘
M’ indicating, respectively, a tagged, modified, saved, preserved, unread, new, or modified message, in that order with the last matching condition being the one displayed. In the case of hidden threads, the entire subthread is searched and the letters above will be displayed in lower case if the property is that of a hidden child with the case ‘
*’ being displayed as ‘
Note 2: %n and %t as used by strftime(3) were redundant with \t and \n, respectively, so nothing is lost using them here.
An option related to dot is ignoreeof which makes mail refuse to accept a ‘
control-D’ as the end of a message. If given a numeric argument n, a ‘
control-D’ will be accepted after n tries. Ignoreeof also applies to mail command mode.
If set, this format string will be inserted before quoting a message (~m or ~M). The format syntax is the same as for header-format. For example, the following:
set indentpreamble= "On %b %e %T, %Y %z (%Z), %n (%.50N) wrote:\n-- Subject: %.65q\n"
would insert something like
On Oct 27 11:00:07, 2006 -0400 (EDT), anon (Anon Ymous) wrote: -- Subject: suggestions for mail(1)
before the quoted message.
- String used by the ~m and ~M tilde escapes for indenting messages, in place of the normal tab character (‘^I’). Be sure to quote the value if it contains spaces or tabs.
If set, this format string will be inserted after quoting a message (~m or ~M). The format syntax is the same as for header-format. For example, the following:
set indentpostscript="-- End of excerpt from %.50N"
would insert something like
-- End of excerpt from Anon Ymous
after the quoted message.
MIME-hook for the body of a MIME block of ‘
Content-Type: TYPE/SUBTYPE’. (See MIME Enhancements below.)
Content-type: text’ messages to this character set or ‘
us-ascii’ if the value is empty. If unset, no character set conversion is done.
- The directory to detach files to if the detach command is given no arguments. (See detach.)
This controls overwriting of existing files by the detach command. If set to ‘
ask’ the user will be prompted before overwriting a file. If set to ‘
yes’, or to the empty string, existing target files will be overwritten. If set to ‘
no’, no target files will be overwritten.
If set, encode the body of the message as required. Typically, this is just an issue of whether ‘
quoted-printable’ encoding is used or not. If it has a value, then use it to determine the encoding type. Allowed values are ‘
quoted-printable’, or ‘
MIME-hook for the header of a MIME block of ‘
Content-Type: TYPE/SUBTYPE’. (See MIME Enhancements below.)
MIME-hook for MIME block of ‘
Content-Type: TYPE/SUBTYPE’. (See MIME Enhancements below.)
The name of the mbox file. It can be the name of a folder. The default is “
mbox” in the user's home directory.
If defined, it specifies the prompt to use when in command mode. Otherwise, the default ‘
&’ is used. The format syntax is the same as for header-format.
- If defined, gives the pathname of the file used to record all outgoing mail. If not defined, then outgoing mail is not so saved.
If set, regular expression searches are used, instead of simple case insensitive substring matches, when determining message lists by searching sender names, subjects, or header fields (if searchheaders is defined); see the Specifying messages section. The value of the variable is a space or comma delimited list of options. Valid options are ‘
icase’ to do case insensitive searches, ‘
extended’ to use extended (rather than basic) regular expressions, and ‘
nospec’ to turn off all special character meanings and do literal string searches. Note that ‘
extended’ and ‘
nospec’ are not compatible (see regcomp(3)).
This is used when replying to email (see the reply or Reply commands). It is useful if you have multiple email addresses and wish to ensure that replies respect them. If set, grab the email address(es) from the ‘
To’ field of the message being replied to. If there is only one such address, and if it does not match any address in the value of ReplyAsRecipient (a comma or space delimited list of addresses, possibly empty), then use this address in the ‘
From’ field of the reply. This is accomplished by passing the address to sendmail(1) with the -f option. Note: the sendmail options can be edited with the ~h escape. (See also the smopts command.)
- If defined, gives the number of lines of a message to be printed out with the top command; normally, the first five lines are printed.
MIME EnhancementsA MIME message is (recursively) divided into a series of MIME parts that can be thought of as sub-messages, each with a header and body. When MIME support is enabled (by setting mime-decode-message), mail splits a message into a series of its smallest MIME parts and processes those parts as if they were messages themselves, passing the header and body through a pipeline of the form:
mail -> MIME-decoder -> MIME-hook -> pager -> screen
The MIME-decoder decodes ‘
base64’ or ‘
quoted-printable’ encoding and is enabled according to the ‘
Content-Transfer-Encoding’ of the part. The MIME-hook is an external program to further process the part (see below). The pager is the program that pages the message (see PAGER). Any of these intermediate pipe stages may be missing and/or different for the head and body of each MIME part. Certain ‘
Content-Types’ may disable the entire pipeline (e.g., ‘
The MIME-hook stage is not present unless one of the following variables is set:
mime-hook-TYPE-SUBTYPE applies to the entire MIME part mime-head-TYPE-SUBTYPE applies to the header of the MIME part mime-body-TYPE-SUBTYPE applies to the body of the MIME part
where TYPE and SUBTYPE are the ‘
Content-Type’ type and subtype (respectively) of the MIME part to which the hook applies. If the “-SUBTYPE” is missing, any subtype is matched. The value of these variables has the format:
where the command is expected to read from stdin and write to stdout, and the possible flags are
- Execute command in a sub-shell rather than doing an exec(3) (see SHELL).
Use this hook when selecting the part to display in a ‘
multipart/alternative’ block. Multipart blocks contain “alternative” versions with the same information, in increasing order of preference (and decoding complexity). The last one the mail agent understands is the one to be displayed. This is typically used for sending a message in both “plain text” and “html”, but more complex subtypes are also possible.
- Do not decode before executing command.
If your command begins with one of these flags, precede it with a space to signal the end of the flags.
WARNING: automatically running a program is a potential security risk if that program has bugs, so be careful what you run.
Examples: View all ‘
Content-Type: image/jpeg’ parts with xv(1) (assuming it is installed):
set mime-body-image-jpeg="/usr/pkg/bin/xv -"
Decode all ‘
Content-Type: images/*’ blocks with uudeview(1) (assuming it is installed), placing the results in /tmp:
set mime-hook-image="-/usr/pkg/bin/uudeview -p /tmp -i -a +o -q -"
Read all ‘
Content-Type: text/html’ parts using lynx(1) (assuming it is installed) and add this support to ‘
set mime-body-text-html="+/usr/pkg/bin/lynx -force_html -dump -stdin"
ENVIRONMENTmail uses the HOME, TMPDIR, and USER environment variables.
- Post office. This can be overwritten by setting the MAIL environment variable.
- User's old mail. This can be overritten by setting the MBOX environment variable.
- File giving initial mail commands. This can be overridden by setting the MAILRC environment variable.
- Temporary files.
- Help files.
- System initialization file.
SEE ALSOfmt(1), newaliases(1), sendmail(1), vacation(1), aliases(5), mailaddr(7) and
The Mail Reference Manual.
HISTORYA mail command appeared in Version 6 AT&T UNIX. This man page is derived from “The Mail Reference Manual” originally written by Kurt Shoens.
BUGSThere are some flags and commands that are not documented here. Most are not useful to the general user.
Usually, mail is just a link to Mail, which can be confusing.
The name of the alternates list is incorrect English (it should be “alternatives”), but is retained for compatibility.
There must be sufficient space on $TMPDIR for various temporary files.
If an unrecoverable character set conversion error occurs (during display), the message is truncated and a warning is printed. This seems to be rare, but probably the remainder of the message should be printed without conversion.
The internal sh-like parser is not terribly sh-like.
Selecting messages by their content (i.e., with ‘
/body:’) is rather slow.
|December 15, 2014||NetBSD 7.0|