mailbox { # Use specified url as a mailspool. mail-spool url; # Create mailbox url using pattern. mailbox-pattern pattern; # Default mailbox type. mailbox-type type; # Default user mail folder. folder dir; }
The mailbox
statement configures the location, name and type of
user mailboxes.
The mailbox location can be specified using mail-spool
or
mail-pattern
statements.
The
mail-spool
statement specifies directory that holds user mailboxes. Once this statement is given, the libmailutils library will assume that the mailbox of user login is kept in file path/login.Historically, path can contain mailbox type prefix, e.g.: ‘maildir:///var/spool/mail’, but such usage is discouraged in favor of
mailbox-pattern
statement.
The
mailbox-pattern
statement is a modern way of configuring mailbox locations. It supersedesmail-spool
statement.The pattern is valid mailbox URL, which may contain references to ‘user’ macro-variable (see macro-variables (Editor's note: dangling link)). This macro-variable will be expanded to the actual user name. The full syntax for pattern is:
[type://]path[;args]where:
- type
- Specifies the mailbox type. It must be one of mailbox types, supported by Mailutils. See Mailbox URLs (Editor's note: dangling link). By default, ‘local’ is assumed.
Editor's note:Verify this
.
- path
- The path pattern.
- args
- A semicolon-separated list of optional arguments, configuring indexed directory structure.
An indexed directory structure is a special way of storing mailboxes, which allows for faster access in case of very large number of users.
By default, all user mailboxes are stored in a single directory and are named after user login names. To find the mailbox for a given user, the system scans the directory for the corresponding file. This usually implies linear search, so the time needed to locate a mailbox is directly proportional to the ordinal number of the mailbox in the directory.
GNU Mailutils supports three types of indexed directories: ‘direct’, ‘reverse’, and ‘hashed’.
In direct indexed directory structure, path contains 26 subdirectories named with lower-case letters of Latin alphabet. The location of the user mailbox is determined using the following algorithm:
- Take the first letter of the user name.
- Map it to a lower-case letter using index mapping table. The result gives sub-directory name.
- Descend into this directory.
For example, using this algorithm, the mailbox of the user ‘smith’ is stored in file path/s/smith.
If each of single-letter subdirectories contains the indexed directory structure, we have second level of indexing. In this case the file name of ‘smith’'s mailbox is path/s/m/smith.
The reverse indexed structure uses the same principles, but the indexing letters are taken from the end of the user name, instead of from the beginning. For example, in the 2nd level reverse indexed structure, the ‘smith’'s mailbox is located in path/h/t/smith.
Finally, the hashed structure consists of 256 subdirectories under path, named by 2-letter hex codes from ‘00’ to ‘FF’. Mailboxes are stored in these subdirectories. The name of the subdirectory is computed by hashing first level letters of the user name. The hashing algorithm is:
- Take next letter from the user name
- Add its ASCII value to the hash sum.
- Continue (1-2) until level letters are processed, or all letters from the file name are used, whichever occurs first.
- Convert the computed sum modulo 256 to a hex code.
Indexed directory structures are configured using the following arguments:
- type=value
- Specifies type of indexing. Valid values are ‘index’, for direct indexed structure, ‘rev-index’ for reverse indexing, and ‘hash’ for hashed structure.
- param=number
- Specifies indexing level.
- user=string
- Specifies indexing key. The only meaningful value, as of Mailutils version 2.99.97 is ‘user=${user}’.
Let's assume the traditional mail layout, in which user incoming mails are stored in UNIX mailbox format in /var/mail directory. The
mailbox-pattern
for this case is:mailbox-pattern "/var/mail/${user}";It is entirely equivalent to specifying ‘mail-spool "/var/mail"’.
Now, if the layout is the same, but mailboxes are kept in ‘maildir’ format, then the corresponding statement is:
mailbox-pattern "maildir:///var/mail/${user}";Finally, if the mailboxes are stored in a directly-indexed directory with two levels of indexing, than:
mailbox-pattern "maildir:///var/mail;type=index;param=2;user=${user}";
If neither mailbox-pattern
nor mail-spool
are given, the
mailbox names are determined using the following algorithm:
The built-in mail spool directory name is determined at compile time, using ‘_PATH_MAILDIR’ define from the include file paths.h. If this value is not defined, /var/mail or /usr/spool/mail is used.
Specifies type of mailboxes. By default, ‘mbox’ (UNIX mailbox) is assumed. This can be changed while configuring the package by setting
MU_DEFAULT_SCHEME
configuration variable. The default value can be verified by running mailutils-config --info scheme.
Sets user mail folder directory. Its value is using when expanding ‘plus-notation’, i.e. such mailbox names as +inbox. The ‘+’ sign is replaced by dir, followed by a directory separator (‘/’).
The dir argument can contain mailbox type prefix, e.g ‘mh://Mail’.
The default folder name is ‘Mail/’.