Appendices
Indices
gnu Mailutils contains a series of useful mail clients, servers, and libraries. These are the primary mail utilities of the GNU system. Specifically, this package contains a POP3 server, an IMAP4 server, and a Sieve mail filter. It also provides a POSIX `mailx' client, and a collection of other tools. The central library is capable of accessing different mailbox formats and mailers as well as off of local or remote POP3 and IMAP4 servers.
This software is part of the GNU Project and belongs to the Free Software Foundation. All libraries are licensed using the GNU LGPL. The documentation is licensed under the GNU FDL, and everything else is licensed using the GNU GPL.
This package started off to try and handle large mailbox files more gracefully then current POP3 servers did. While it handles this task, it also allows you to support a variety of different mailbox formats without any real effort on your part. Also, if a new format is added at a later date, your program will support that new format automatically as soon as it is compiled against the new library.
gnu Mailutils provides a set of programs for handling the e-mail.
There are some command line options that are used so often that it is inconvenient to specify them in the command line each time you run a Mailutils utility. The configuration files provide a way to add default command line arguments without having to type them in the command line. Upon startup, each Mailutils utility scans and processes the contents of the three startup files, none of which are required to exist:
mailutils.rc, found in your your system configuration directory (usually /etc or /usr/local/etc).
Usually ~/.mailutils, unless ~/.mailutils is a directory, in which case ~/.mailutils/mailutils is used.
Usually ~/.mu.programrc, unless ~/.mailutils is a directory, in which case ~/.mailutils/programrc is used (where program means the program name).
These files have simple line-oriented syntax. Comments begin with the pound sign (‘#’) and extend through the end of the line 1. Very long lines may be split across several lines by escaping final newline with a backslash (‘\’) character.
In the non-program-specific configuration files, any configuration line must start with a tag. In the program-specific configuration file the tag must not be present, all options are for that specific program.
A tag is either a name of a particular Mailutils utility or option group, prefixed with colon (‘:’). The command line options common for several Mailutils programs are divided into option groups or capabilities, e.g. the options --mail-spool and --lock-flags form group ‘mailbox’. These groups are discussed in detail below.
When processing the non-program-specific configuration files, a Mailutils utility selects those lines whose tag is either the name of that utility or the name of the option group supported by it. In the program-specific configuration file, all lines are selected. For each line found, its tag (if present) is stripped away, and the rest of the line is split up into words. These words are regarded as command line options and are inserted to the program arguments before any options from the command line. Thus the options from .mailutils take precedence over those from mailutils.rc, and the options from the command line take precedence over those from all three configuration files.
The word splitting occurs at whitespace characters and is similar to that performed by the shell. If an option must contain embedded whitespace, it should be enclosed in a pair of quotes (either double or single quotes).
Each program understands the following informational options:
Option group ‘mailbox’ consists of options used to specify the location of the mail spool, and the locking strategy.
This option group overrides the default mailer URL (sendmail:).
Option group ‘address’ consists of options used to specify how to qualify email addresses.
An unqualified address (one without an @) is qualified by appending
@defaultdomain. defaultdomain is the return of
gethostname(), or the result of gethostbyname() on the return
of gethostname() (if the DNS lookup is successful).
If the email address of the current user is needed, either the address set by --email-addr is returned, or the current uid is looked up in the user database, and qualified with the defaultdomain.
These options control the authorization and authentication module lists. For a description of authentication concepts, refer to See authentication.
The following options exist in this group if the package was configured with --enable-sql option. They take effect only if the ‘sql’ module is used in authentication and/or authorization.
mailutils was compiled with support for several
sql drivers.
If this option is omitted, mailutils will use the first
available sql driver.
These options control TLS/SSL encryption in imap4d and pop3d daemons.
The following options comprise this group:
The following configuration file specifies that all Mailutils programs should use /var/spool/mail as a local mailspool directory. Programs performing authentication will use pam service ‘mailutils’. All programs, except imap4d will issue log messages via ‘mail’ facility, imap4d will use facility ‘local1’.
:mailbox --mail-spool /var/spool/mail
:auth --authentication pam --pam-service mailutils
:logging --log-facility mail
imap4d --daemon=20 --timeout=1800 --log-facility local1
Some mail utilities provide access to their services only after verifying that the user is actually the person he is claiming to be. Such programs are, for example, pop3d and imap4d. The process of the verification is broken down into two stages: authorization and authentication. In authorization stage the program retrieves the information about a particular user. In authentication stage, this information is compared against the user-supplied credentials. Only if both stages succeed is the user allowed to use the service.
A set of modules is involved in performing each stage. For example, the authorization stage can retrieve the user description from various sources: system database, sql database, virtual domain table, etc. Each module is responsible for retrieving the description from a particular source of information. The modules are arranged in a module list. The modules from the list are invoked in turn, until either a one of them succeeds or the list is exhausted. In latter case the authorization fails. Otherwise the data returned by the succeeded module are used in authentication.
Similarly, authentication may be performed in several ways. The authentication modules are also grouped in a list. Each module is tried in turn until either a module succeeds, in which case the authentication succeeds, or the end of the list is reached.
We represent the module lists as column-separated lists of module names. For example, the authorization list
system:sql:virtdomains
means that first the system user database (/etc/password) is searched for a description of a user in question. If the search fails, the sql database is searched. Finally, if it also fails, the search is performed in the virtual domain database.
Note, that some authentication and/or authorization modules may be disabled when configuring the package before compilation. The names of the disabled modules are nevertheless available for use in runtime configuration options, but they represent a “fail-only” functionality, e.g. if the package was compiled without sql support then the module ‘sql’ in the above example will always fail, thus passing the execution on to the next module.
The modules available for use in authorization list are:
The modules available for use in authentication list are:
Unless overridden by --authentication command line option, the list of authentication modules is:
generic:system:pam:sql
Unless overridden by --authorization command line option, the list of authorization modules is:
system:sql:virtdomains
GNU mailutils provides two commands for listing messages in a mailbox. These are from and frm.
The frm command outputs a header information of
the selected messages in a mailbox. By default, frm reads the
user's system mailbox and outputs the contents of From and
Subject headers for each message. If a folder is specified in
the command line, the program reads that folder rather than the default
mailbox.
The program uses following option groups: See mailbox.
The following command line options alter the behavior of the program:
From
Subject pair.
To header to the output. The output field
order is then: To From Subject.
The from utility displays sender and subject of each message in a mailbox. By default, it reads the user's system mailbox. If the program is given a single argument, it is interpreted as a user name whose mailbox is to be read. Obviously, permissions are required to access that user's mailbox, so such invocations may be used only by superuser.
Option -f (--file) instructs the program to read the given mailbox.
The full list of options, supported by from follows:
From: header is examined.
Mail is an enhanced version of standard /bin/mail program. As well as its predecessor, it can be used either in sending mode or in reading mode. Mail enters sending mode when one or more email addresses were specified in this command line. In this mode the program waits until user finishes composing the message, then attempts to send it to the specified addresses and exits. See Composing Mail, for a detailed description of this behavior.
If the command line contained no email addresses, mail switches to reading mode. In this mode it allows to read and manipulate the contents of a mailbox. The URL of the mailbox to operate upon is taken from the argument of --file command line option. If it is not specified, the user's system mailbox is assumed. For more detail, see Reading Mail.
General usage of mail program is:
mail [option...] [address...]
If [address...] part is present, mail switches to mail sending mode, otherwise it operates in mail reading mode.
The program uses following option groups: See mailbox.
Mail understands following command line options:
print *
quit
mail -f/spool_path/user
with spool_path being the full path to your mailspool directory
(/var/spool/mail or /var/mail on most systems).
Many mail commands such as print and delete can be given a message list to operate upon. Wherever the message list is omitted, the command operates on the current message.
The message list in its simplest form is one of:
In its complex form, the message list is a comma or whitespace-separated list of message specifiers. A message specifier is one of
[header:]/string/
It selects all messages that contain header field header
matching given regexp. If the variable regexp is set,
the string is assumed to be a POSIX regexp. Otherwise, a
header is considered to match string if the latter constitutes
a substring of the former (comparison is case-insensitive).
If header: part is omitted, it is assumed to be ‘Subject:’.
:/string/
It selects all messages whose body matches the string. The matching rules are the same as described under “Header match”.
A message specifier can be followed by message part specifier, enclosed in a pair of brackets. A message part specifier controls which part of a message should be operated upon. It is meaningful only for multipart messages. A message part specifier is a comma or whitespace - separated list of part numbers or ranges. Each part number can in turn be message part specifier, thus allowing for operating upon multiply-encoded messages.
The following are the examples of valid message lists:
You can compose the message by simply typing the contents of it, line
by line. But usually this is not enough, you would need to edit
your text, to quote some messages, etc. Mail provides these
capabilities through compose escapes. The compose escapes
are single-character commands, preceded by special escape character,
which defaults to ‘~’. The combination escape character + command
is recognized as a compose escape only if it occurs at the beginning of
a line. If the escape character must appear at the beginning of a
line, enter it twice.
The actual escape character may be changed by setting the value of
escape mail variable (see Mail Variables).
There are several commands allowing you to quit the compose mode.
Typing the end-of-file character (‘C-D’) on a line alone finishes
compose mode and sends the message to its destination. The ‘C-D’
character looses its special meaning if ignoreeof mail variable
is set.
If mail variable dot is set, typing dot (‘.’) on a line
alone achieves the same effect as ‘C-D’ above.
Finally, using ‘~.’ escape always quits compose mode and sends out the composed message.
To abort composing of a message without sending it, type interrupt
character (by default, ‘C-C’) twice. This behavior is disabled
when mail variable ignore is set. In this case, you can use
‘~x’ escape to achieve the same effect.
The ‘~?’ escape prints on screen a brief summary of the available compose escapes. Please note, that ‘~h’ escape prompts for changing the header values, and does not give help.
If you are not satisfied with the message as it is, you can edit it
using a text editor specified either by EDITOR or by
VISUAL environment variables. The ‘~e’ uses the former,
and ‘~v’ uses the latter.
By default both escapes allow you to edit only the body of the
message. However, if the editheaders variable is set,
mail will load into the editor the complete text of
the message with headers included, thus allowing you to change
the headers as well.
To add new addresses to the list of message recipients, use ‘~t’ command, e.g.:
~t name1@domain.net name2
To add addresses to Cc or Bcc, use ‘~c’ or ‘~b’
escapes respectively.
To change the Subject header, use ‘~s’ escape, e.g.:
~s "Re: your message"
Finally, to edit all headers, type ‘~h’ escape. This will present
you with the values of To, Cc, Bcc, and
Subject headers allowing to edit them with normal text editing
commands.
If you are sending mail from within mail command mode, you can enclose the contents of any message sent to you by using ‘~m’ or ‘~M’ commands. Typing ‘~m’ alone will enclose the contents of the current message, typing ‘~m 12’ will enclose the contents of message #12 and so on.
The ‘~m’ uses retained and ignored lists when enclosing headers, the ‘~M’ encloses all header fields.
In both cases, the contents of indentprefix mail variable is
prepended to each line enclosed.
To append the contents of file filename to the message, type
~r filename
or
~< filename
The ‘~d’ escape is a shorthand for
~r dead.letter
The ‘~p’ escape types the contents of the message entered so far, including headers, on your terminal. You can save the message to an arbitrary file using ‘~w’ escape. It takes the filename as its argument.
To save you the effort of typing your signature at the end of each
message, you can use ‘~a’ or ‘~A’ escapes. If your signature
occupies one line only, save it to the variable sign and use
‘~a’ escape to insert it. Otherwise, if it is longer than one
line, save it to a file, store the name of this file in the
variable Sign, and use ‘~A’ escape to insert it into
the message.
Sometimes it is necessary to view the contents of another message, while composing. These two escapes allow it. Both take the message list as their argument. If they are used without argument, the contents of the current message is printed. The difference between ‘~f’ and ‘~F’ is that the former uses ignored and retained lists to select headers to be displayed, whereas the latter prints all headers.
The ‘~i’ escape enters the value of the named mail variable into the body of the message being composed.
You can execute a mail command from within compose mode using ‘~:’ or ‘~-’ escapes. For example, typing
~: from :t
will display the from lines of all tagged messages. Note, that executing
mail-sending commands from within the compose mode is not allowed.
An attempt to execute such a command will result in diagnostic message
“Command not allowed in an escape sequence” being displayed.
Also, when starting compose mode immediately from the shell
(e.g. running ‘mail address@domain’), most mail commands are
meaningless, since there is no mailbox to operate upon. In this case,
the only commands that can reasonably be used are: alias,
unalias, alternate, set, and unset.
The ‘~!’ escape executes specified command and returns you to mail compose mode without altering your message. When used without arguments, it starts your login shell. The ‘~|’ escape pipes the message composed so far through the given shell command and replaces the message with the output the command produced. If the command produced no output, mail assumes that something went wrong and retains the old contents of your message.
To read messages from a given mailbox, use one of the following ways of invoking mail:
mailmail --filemail --file=path_to_mailboxmail --user=userPlease note, that usual mailbox permissions won't allow you to use the last variant of invocation, unless you are a super-user. Similarly, the last but one variant is also greatly affected by the permissions the target mailbox has.
Unless you have started mail with --norc command line option, it will read the contents of the system-wide configuration file. Then it reads the contents of user configuration file, if any. For detailed description of these files, see Mail Configuration Files. After this initial setup, mail displays the first page of header lines and enters interactive mode. In interactive mode, mail displays its prompt (‘?’, if not set otherwise) and executes the commands the user enters.
Following commands quit the program:
delete are removed.
The program exits to the Shell, unless saving the mailbox fails, in
which case user can escape with the exit command.
Typing EOF (‘C-D’) alone is equivalent to ‘quit’.
Following commands can be used during the session to request online help:
quit command has been issued.
If mailbox is omitted, the command prints the current mailbox
name followed by the summary information regarding it, e.g.:
| & fold "/var/spool/mail/gray": 23 messages 22 unread |
To control which headers in the message should be displayed, mail keeps two lists: a retained header list and an ignored header list. If retained header list is not empty, only the header fields listed in it are displayed when printing the message. Otherwise, if ignored header list is not empty, only the headers not listed in this list are displayed. The uppercase variants of message-displaying commands can be used to print all the headers.
The following commands modify and display the contents of both lists.
headers
command. When arg is ‘.’, it is generally equivalent to
headers. When arg is omitted or is ‘+’, the next
pageful of headers is displayed. If arg is ‘-’, the
previous pageful of headers is displayed. The latter two forms
of z command may also take a numerical argument meaning the
number of pages to skip before displaying the headers. For
example:
& z +2
will skip two pages of messages before displaying the header summary.
folder variable.
| & summary "/var/spool/mail/gray": 23 messages 22 unread |
crt
determines the minimum number of lines the body of the message must
contain in order to be piped through pager command specified
by environment variable PAGER. If crt is set to a numeric
value, this value is taken as the minimum number of lines. Otherwise,
if crt is set without a value then the height of the terminal
screen is used to compute the threshold. The number of lines on
screen is controlled by screen variable.
decode command decodes and prints
out specified message parts. E.g.
| & decode 15[2] +--------------------------------------- | Message=15[2] | Type=message/delivery-status | encoding=7bit +--------------------------------------- Content-Type: message/delivery-status ... |
toplines and
defaults to five.
cmd is set,
the value of this variable is used as a command name.
& untag :t
delete command.
quit command these
messages will be deleted from the mailbox. Until the end of current
session the deleted messages can be referred to in message lists using
:d notation.
delete command, unless the variable
keepsave is set.
save, but the file to append messages to is named after the
sender of the first message in msglist. For example:
| & from 14 15 U 14 smith@noldor.org Fri Jun 30 18:11 14/358 The Save c U 15 gray@noldor.org Fri Jun 30 18:30 8/245 Re: The Sa & Save 14 15 "smith" 22/603 |
i.e., 22 lines (603 characters) have been appended to the file “smith”.
If the file does not exist, it is created.
save, except that only message body (without the
header) is saved.
Save, except that only message body (without the
header) is saved.
quit command. This is the default action for
all read messages, unless you have variable hold set.
save, except that saved messages are not marked for
deletion.
Save, except that saved messages are not marked for
deletion.
These command allow to edit messages in a mailbox. Please note,
that modified messages currently do not replace original ones. i.e.
you have to save them explicitly using your editor's save
command if you do not want the effects of your editing to be lost.
EDITOR environment variable.
VISUAL environment variable.
reply, except that the composed message is sent only to
originators of the specified messages.
Notice, that setting mail variable flipr (see Mail Variables) swaps the meanings of the two above commands,
so that reply sends the message to the sender and all
recipients of the message, whereas Reply sends it to
originators only.
followup, but reply message is sent only to
originators of messages in msglist.
To determine the sender of the message mail uses the list of sender fields (see Controlling Sender Fields). The first field from this list is looked up in message headers. If it is found and contains a valid email address, this address is used as the sender address. If not, the second field is searched and so on. This process continues until a field is found in the headers, or the sender field list is exhausted, whichever happens first.
If the previous step did not determine the sender address, the address from SMTP envelope is used.
Let's illustrate this. Suppose your mailbox contains the following:
| U 1 block@helsingor.org Fri Jun 30 18:30 8/245 Re: The Sa & Print 1 From: Antonius Block <block@helsingor.org> To: Smeden Plog <plog@helsingor.org> Date: Tue, 27 Apr 2004 13:23:41 +0300 Reply-To: <root@helsingor.org> Subject: News Hi |
Now, you issue the following commands:
| & sender mail-followup-to reply-to from & reply To: <root@helsingor.org> Subject: Re: News |
As you see, the value of Reply-To field was taken as the
sender address.
Now, let's try the following command sequence:
# Clear the sender list
& nosender
# Set new sender list
& sender From
Now, the From address will be taken:
| & reply To: Antonius Block <block@helsingor.org> Subject: Re: News |
Commands sender and nosender are used to manipulate
the contents of the sender field list.
If the command sender is used without arguments, it displays
the contents of the sender field list. If arguments are given,
each argument is appended to the sender field list. For example:
| & sender Sender address is obtained from the envelope & sender mail-followup-to reply-to & sender mail-followup-to reply-to & sender from & sender mail-followup-to reply-to from |
Command nosender is used to remove items from the sender
field list:
| & sender mail-followup-to reply-to from & nosender reply-to & sender mail-followup-to from |
When used without arguments, this command clears the list:
| & nosender Sender address is obtained from the envelope |
The incorporate (inc) command incorporates newly arrived
messages to the displayed list of messages. This is done automatically
before returning to mail command prompt if the variable
autoinc is set.
To run arbitrary shell command from mail command prompt, use
shell (sh) command. If no arguments are specified, the
command starts the user login shell. Otherwise, it uses its first
argument as a file name to execute and all subsequent arguments are
passed as positional parameters to this command. The shell
command can also be spelled as !.
The ‘#’ character introduces an end-of-line comment. All characters until and including the end of line are ignored.
The ‘echo’ (‘ec’) command prints its arguments to stdout.
The command ‘source filename’ reads commands from the named file. Its minimal abbreviation is ‘so’.
The mail variables may be set using ‘set’ (‘se’) command. The command takes a list of assignments. The syntax of an assignment is
True value.
False value.
Example:
& set askcc nocrt indentprefix="> "
This statement sets askcc to True, crt to
False, and indentprefix to “> ”.
To unset mail variables use ‘unset’(‘uns’) command. The command takes a list of variable names to unset.
Example: To undo the effect of the previous example, do:
& unset askcc crt indentprefix
Shell environment may be modified using ‘setenv’ (‘sete’) command. The command takes a list of assignments. The syntax of an assignment is:
The conditional statement allows to execute a set of mail commands depending on the mode the mail program is in. The conditional statement is:
if cond
...
else
...
endif
where ‘...’ represents the set of commands to be executed in each branch of the statement. cond can be one of the following:
The conditional statements can be nested to arbitrary depth. The minimal abbreviations for ‘if’, ‘else’ and ‘endif’ commands are ‘i’, ‘el’ and ‘en’.
Example:
if t
set crt prompt="& "
else
unset prompt
endif
if s
alt gray@farlep.net gray@mirddin.farlep.net
set
Following variables control the behavior of gnu mail:
appenddeadletterTrue, the contents of canceled letter is
appended to the user's dead.letter file. Otherwise it overwrites
its contents.
askbccTrue the user will be prompted to enter Bcc
field before composing the message.
askccTrue the user will be prompted to enter Cc
field before composing the message.
asksubTrue the user will be prompted to enter Subject
field before composing the message.
autoincautoprintbang! in arguments to !
command is replaced with the last executed command.
datefieldDate: header field, converted to
localtime. Notice, that for messages lacking this field mail
will fall back to using SMTP envelope.
charsetLC_ALL environment
variable. Otherwise, its value is taken as the name of the charset.
cmdpipe.
columnsCOLUMNS is used.
This variable contains the number of columns on terminal screen.
crtcrt determines the minimum number of lines the body
of the message must contain in order to be piped through pager command
specified by environment variable PAGER. If crt is set
to a numeric value, this value is taken as the threshold. Otherwise,
if crt is set without a value, then the height of the terminal
screen is used to compute the threshold. The number of lines on
screen is controlled by screen variable.
decode-fallbackdotTrue, causes mail to interpret a period alone on a line as the
terminator of a message you are sending.
emptystarteditheaders~e and ~v escapes, thus allowing you to customize
the headers.
escapefliprflipr if set swaps the meanings of reply
and Reply commands (see Replying).
folderheaderheaders command automatically after entering
interactive mode.
holdTrue, the read or saved messages will be stored in
user's mailbox ($HOME/mbox). Otherwise, they will be held in
system mailbox also. This option is in effect only when operating
upon user's system mailbox.
ignoreTrue, mail will ignore keyboard interrupts
when composing messages. Otherwise an interrupt will be taken as a
signal to abort composing.
ignoreeofindentprefix~m tilde escape for indenting quoted messages.
inplacealiasesIf set, mail will expand aliases in the address header field
before entering send mode (see Composing Mail). By default, the
address header fields are left intact while composing, the alias
expansion takes place immediately before sending message.
keepsavemailxCc and Bcc addresses after composing the body.
The default behavior is to ask for these values before composing
the body.
metamaildecode command. If
it is unset, decode will not attempt any interpretation
of the content of message parts. Otherwise, if metamail
is set to true, decode will use internal metamail
support to interpret message parts. Finally, if metamail
is assigned a string, this string is treated as command line of
the external metamail command which will be used to
display parts of a multipart message. For example:
# Disable MIME interpretation:
set nometamail
# Enable built-in MIME support:
set metamail
# Use external program to display MIME parts:
set metamail="metamail -m mail -p"
mimenoaskset mimenoask=text/*,image/jpeg
will disable prompting before displaying any textual files, no
matter what their subtype is, and before displaying files with
type ‘image/jpeg’.
metoomodenullbodytrue, means such messages are sent,
and a warning (traditionally saying ‘Null message body; hope
that's ok’) is displayed. The text of the warning can be set using
nullbodymsg variable (see below).
If nullbody is unset, mail will silently ignor