Go to the first, previous, next, last section, table of contents.


22 The aliasfile director

The `aliasfile' director expands local parts by consulting a file of aliases. The expansion may safely contain the same local part, because a director is automatically skipped if any ancestor of a local part has the same name and was processed by that director.

The alias file can be a text file that is searched linearly, a DBM direct-access database, a NIS or NIS+ map, or any other kind of lookup supported by Exim (see chapter "File and database lookups"). The case of letters is not significant in searches. The `exim_dbmbuild' utility can be used to convert a text file into a DBM database; the keys are lower-cased by this process.

22.1 Alias file format

A textual alias file to be searched linearly consists of entries that start with the alias name, terminated by a colon. The remainder of the entry consists of a list of addresses, file names, pipe commands, or certain special items (see below). The items in the list are separated by commas. The list can be continued over several lines by starting each of the continuation lines with white space. A comma is still required following an item that ends at the end of a line, because the `lsearch' lookup code removes newlines from the string it returns.

By default, alias names are simple local parts such as `postmaster', but if the `include_domain' option is set, they must contain both a local part and a domain, thus allowing aliases for more than one domain to be held in a single file.

Lines in the alias file that start with a # character are comments, and are ignored, and a &&s may also appear following a comma in an item list, in which case everything after the &&s is ignored.

Other forms of alias file (DBM, NIS, etc.) involve lookups using the local part as a key on files and databases that return a list of address, file, or pipe items separated by commas or newlines.

22.2 Types of alias item

If an item is entirely enclosed in double quotes, these are removed, but otherwise double quotes are retained, because some forms of mail address require their use (but never to enclose the entire address). In the following description, `item' refers to what remains after any surrounding double quotes have been removed. An item may safely be the same as the one currently under consideration, because any director is automatically skipped if any ancestor has the same local part and was processed by that director.

22.3 Duplicate addresses

Exim removes duplicate addresses from the list to which it is delivering, so as to deliver just one copy to each address. This does not apply to deliveries directed at pipes by different immediate parent addresses, but an indirect aliasing scheme of the type


pipe:       |/some/command ${local_part}
localpart1: pipe
localpart2: pipe

does not work with a message that is addressed to both local parts, because when the second is aliased to the intermediate local part `pipe' it gets discarded as being the same as a previously handled address. However, a scheme such as


localpart1: |/some/command ${local_part}
localpart2: |/some/command ${local_part}

does result in two different pipe deliveries, because the immediate parents of the pipes are distinct.

22.4 Errors in alias files

If `skip_syntax_errors' is set, a malformed address that causes a parsing error is skipped, and an entry is written to the main log. This may be useful for mailing lists that are automatically managed, but note the inherent danger. Otherwise, if an error is detected while generating the list of new addresses, the message is frozen, except for the special case of inability to open an included file, when `no_freeze_missing_include' is set. In this case, delivery is simply deferred.

22.5 Specifying a transport

If a transport is specified for this director, then the message is directed to that transport for any local part which is found in the file, any data in the file that is associated with the local part being ignored (so it isn't really `aliasing' in this case). Thus the same processing can be done for any local part that is listed in the file. For example, a file containing a list of cancelled users can be used to direct messages addressed to them to a particular script.

22.6 Aliasfile private options

check_ancestor (aliasfile) option

Option: check_ancestor
Type: boolean
Default: false

When this option is set, if a generated address is the same as any ancestor of the current address, then it is not used, but instead the current address gets passed on to subsequent directors. In the default case, this happens only if the ancestor was processed by the current director. See the `check_ancestor' option on the `forwardfile' director for more details.

current_directory (aliasfile) option

Option: current_directory
Type: string
Default: unset

This option associates a current directory with any address that `aliasfile' directs to a local transport. This can happen either because a transport is explicitly configured for the director, or because it generates a delivery to a file or a pipe. The option string is expanded and is set as the current directory during the delivery process, unless overridden by a setting on the transport. See chapter "Environment for running local transports" for details of the local delivery environment.

directory (aliasfile) option

Option: directory
Type: string
Default: unset

This option is obsolete, having been replaced by `current_directory' and `home_directory'. If used, it sets the value of `home_directory'.

directory_transport (aliasfile) option

Option: directory_transport
Type: string
Default: unset

An `aliasfile' director sets up a direct delivery to a directory when a path name ending with a slash is specified as a new `address' (see chapter "Default transports"). The transport used is taken from the global option `address_directory', unless this option is set to override it. The string must be the name of a configured transport.

directory2_transport (aliasfile) option

Option: directory2_transport
Type: string
Default: unset

An `aliasfile' director sets up a direct delivery to a directory when a path name ending with two slashes is specified as a new `address' (see chapter "Default transports"). The transport used is taken from the global option `address_directory2', unless this option is set to override it. The string must be the name of a configured transport.

errors_to (aliasfile) option

Option: errors_to
Type: string
Default: unset

This used to exist as an option specific to this director, but it is now a generic option that can be used on any director or router (see chapter "Common generic options for directors and routers").

expand (aliasfile) option

Option: expand
Type: boolean
Default: false

If this option is set true, then the text obtained by looking up the local part is passed through the string expansion mechanism before being interpreted as a list of alias items. Addresses that are subsequently added by means of the `include' mechanism are not expanded.

file (aliasfile) option

Option: file
Type: string
Default: unset

This option specifies the name of the alias file, and it must be set if `search_type' specifies a single-key lookup; if it does not, an error occurs. (For query-style lookups, `query' must be set instead.) See chapter "File and database lookups" for details of different lookup styles. The string is expanded before use; if expansion fails, Exim panics. The resulting string must be an absolute path for linear search and DBM lookups. If the original string does not start with `/' or `$' in these cases, Exim gives a configuration error when it starts up; otherwise, if an expanded string does not begin with `/' delivery is frozen.

file_transport (aliasfile) option

Option: file_transport
Type: string
Default: unset

An `aliasfile' director sets up a direct delivery to a file when a path name not ending in a slash is specified as a new `address' (see chapter "Default transports"). The transport used is taken from the global option `address_file', unless this option is set to override it. The string must be the name of a configured transport.

forbid_file (aliasfile) option

Option: forbid_file
Type: boolean
Default: false

If this option is true, then this director may not generate a new address which specifies delivery to a local file or directory. If it attempts to do so, a delivery failure occurs.

forbid_pipe (aliasfile) option

Option: forbid_pipe
Type: boolean
Default: false

If this option is true, then this director may not generate a new address which specifies delivery to a pipe. If it attempts to do so, a delivery failure occurs.

freeze_missing_include (aliasfile) option

Option: freeze_missing_include
Type: boolean
Default: true

If a file named by the `include' mechanism fails to open, delivery is frozen if this option is true. Otherwise, delivery is just deferred. Unsetting this option can be useful if included files are NFS mounted and may not always be available.

group (aliasfile) option

Option: group
Type: string
Default: unset

If a file or pipe delivery is generated by this director, and the transport does not specify a user and group, then the user and group given here are used when running the delivery process. If the string contains no $ characters, it is resolved when Exim starts up. Otherwise, the string is expanded at the time the director is run, and must yield either a digit string or a name which can be looked up using `getgrnam()'.

home_directory (aliasfile) option

Option: home_directory
Type: string
Default: unset

This option associates a home directory with any address that `aliasfile' directs to a local transport. This can happen either because a transport is explicitly configured for the director, or because it generates a delivery to a file or a pipe. The option string is expanded and is set as the home directory during the delivery process, unless overridden by a setting on the transport. See chapter "Environment for running local transports" for details of the local delivery environment.

include_domain (aliasfile) option

Option: include_domain
Type: boolean
Default: false

Setting this option true causes the key that is looked up to be `local-part@domain' instead of just `local-part'. Thus a single file can be used to hold aliases for many local domains. This option has no effect if the search type specifies a query-style lookup.

If you want include defaults for each domain in an alias file in the form


*@domain1:  default@domain1
*@domain2:  default@domain2

then you need to include `*@' in the search type (for example, `dbm*@'). See section "Single-key lookup types" in chapter "File and database lookups" for details of this kind of search.

initgroups (aliasfile) option

Option: initgroups
Type: boolean
Default: false

If a file or pipe delivery is generated by this director, and this option is true, and the `user' option is set, then the `initgroups()' function is called when running the transport to ensure that any additional groups associated with the uid are set up.

modemask (aliasfile) option

Option: modemask
Type: integer
Default: 022

This specifies mode bits which must not be set for the alias file. If they are set, the director fails and the message is frozen.

optional (aliasfile) option

Option: optional
Type: boolean
Default: false

If the file cannot be opened because it does not exist (the ENOENT error) and this option is set, the director simply fails to match the address. Otherwise any failure to open the file causes an entry to be written to the log and delivery to be deferred.

owners (aliasfile) option

Option: owners
Type: string-list
Default: unset

This specifies a list of permitted owners for the alias file. If it is unset, no check on the ownership is done. If the file is not owned by a user in the list, the director fails and the message is frozen.

owngroups (aliasfile) option

Option: owngroups
Type: string-list
Default: unset

This specifies a list of permitted groups for the alias file. If it is unset, no check on the file's group is done. If the file's group is not in the list, the director fails and the message is frozen.

pipe_transport (aliasfile) option

Option: pipe_transport
Type: string
Default: unset

An `aliasfile' director sets up a direct delivery to a pipe when a string starting with a vertical bar character is specified as a new `address' (see chapter "Default transports"). The transport used is taken from the global option `address_pipe', unless this option is set to override it. The string must be the name of a configured transport.

qualify_preserve_domain (aliasfile) option

Option: qualify_preserve_domain
Type: boolean
Default: false

If this is set and an unqualified address (one without a domain) is generated, it is qualified with the domain of the incoming address instead of the global setting in `qualify_recipient'.

queries (aliasfile) option

Option: queries
Type: string
Default: unset

This option is an alternative to `query' and and is mutually exclusive with it. The difference is that `queries' contains a colon-separated list of queries, which are tried in order until one succeeds or defers, or all fail. Any colon characters actually required in an individual query must be doubled, in order that they not be treated as query separators.

query (aliasfile) option

Option: query
Type: string
Default: unset

This option specifies a database query, and either it or `queries' must be set if `search_type' specifies a query-style lookup; if neither is set, an error occurs. (For single-key lookups, `file' must be set instead.) See chapter "File and database lookups" for details of different lookup styles. The query is expanded before use, and would normally contain a reference to the local part. For example,


search_type = nisplus
query = [alias=${local_part}],mail-aliases.org_dir:expansion

could be used for a NIS+ lookup. Sometimes a lookup cannot be completed (for example, a NIS+ database might be inaccessible) and in this case the director causes delivery to be deferred.

rewrite (aliasfile) option

Option: rewrite
Type: boolean
Default: true

If this option is set false, addresses generated by the director are not subject to address rewriting. Otherwise, they are treated like new addresses.

search_type (aliasfile) option

Option: search_type
Type: string
Default: unset

This option must be set to one of the strings `lsearch', `dbm', `nis', `nis0', or `nisplus', specifying the type of data lookup. When the setting is `nisplus', the `query' option specifies the search query, and `file' must not be set. For the other search types, `file' is required and `query' must not be set. See chapter "File and database lookups" for details of the different lookup styles.

Single-key search types for `aliasfile' can be preceded by `partial-' and/or followed by *. The former isn't likely to be useful very often, but the latter provides a default facility. Note, however, that if two addresses in the same message provoke the use of the default, only one copy gets delivered, but any added `Envelope-to:' header contains all the original addresses.

skip_syntax_errors (aliasfile) option

Option: skip_syntax_errors
Type: boolean
Default: false

If `skip_syntax_errors' is set, a malformed address that causes a parsing error is skipped, and an entry is written to the main log. This may be useful for mailing lists that are automatically managed, but note the inherent danger.

syntax_errors_to (aliasfile) option

Option: syntax_errors_to
Type: string
Default: unset

This option applies only when `skip_syntax_errors' is set. If any addresses are skipped because of syntax errors, a mail message is sent to the address specified by `syntax_errors_to', giving details of the failing address(es). Often it will be appropriate to set `syntax_errors_to' to be the same address as the generic `errors_to' option.

user (aliasfile) option

Option: user
Type: string
Default: unset

When a file or pipe delivery is generated by this director, and the transport does not specify a user and group, then the user and group given here are used when running the delivery process. If the string contains no $ characters, it is resolved when Exim starts up. Otherwise, the string is expanded at the time the director is run, and must yield either a digit string or a name which can be looked up using `getpwnam()'.


Go to the first, previous, next, last section, table of contents.