Using another alias source and the alias database

The alias database is a supplement to the alias options (Unified Configuration) or alias file (legacy configuration); it is  not a replacement for them. If the alias database exists, the MTA uses both the usual alias source (the alias options in Unified Configuration, or the alias file in legacy configuration) and the  alias database.

The alias database is consulted once each time the alias options/regular alias file is consulted. However, the alias database is checked before the alias options/regular alias file is consulted. In effect, the database acts as a sort of address rewriter that is invoked prior to using the regular alias source. Although duplicate entries are allowed in the database, it is undefined as to which of the duplicate entries will be returned when  the database is accessed. Database entries are case insensitive.

The fact that limited recursion  is allowed in the  alias options/alias file  makes the  complete translation mechanism rather complex. For example, suppose that the alias file contains the entries, A: C,J B: D,K D: G,H E: I and the alias database contains the entries, D: E C: B  F: D Now suppose the address    was  presented to the MTA. First A would be looked up in the alias database --- not found. Then A would be translated into C and J by the alias file. C would in turn be translated into B by the alias database while J would remain  unchanged. B would then be translated into D and K by the alias file. D would then be translated into E by the alias database while K would remain  unchanged. Finally, E would be translated into I by the alias file, and since I does not appear in the alias database the process would terminate. The final result is that A translates into the list I, J, K.

The easiest way to look at the translation process is to simply follow it step-by-step as illustrated below. Initial Data      Data      Data      Data look up base File base File base File base Result ---        --        A     A    C    B    D    E    I    I      I                             K    K. .     K                   J    J. .   .    .      J        B     B    D    E    I    I. .     I                   K    K. .   .    .      K        C     B    D    E    I    I. .     I                   K    K. .   .    .      K        D     E    I    I. .   .    .      I        E     E    I    I. .   .    .      I        F     D    G    G. .   .    .      G                   H    H. .   .    .      H Such complex use of the aliases facility is not encouraged and is  presented for illustrative purposes only.

Note: In particular, for most normal goals any particular entry should appear in either an alias option/the  alias fileor the alias database,  not in both!

See also:
 * Alias options
 * Alias file
 * Alias recursion and nested list definitions
 * Alias database