Rewrite rules appear in the upper-half of the MTA configuration file, imta.cnf. Each rule in the configuration file appears on a single line. Comments, but not blank lines, are allowed between the rules. The rewrite rules end with a blank line, after which the channel definitions follow. Example 4–1shows the rewrite rule section of a partial configuration file.
! test.cnf - An example configuration file. ! ! This is only an example of a configuration file. It serves ! no useful purpose and should not be used in a real system. ! a $U@a-host b $U@b-host c $U%c@b-daemon d $U%d@a-daemon ! Begin channel definitions Simple Configuration File - Rewrite Rules
Rewrite rules consist of two parts: a pattern, followed by an equivalence string or template. The two parts must be separated by spaces, although spaces are not allowed within the parts themselves. The structure for rewrite rules is as follows:
Indicates the string to search for in the domain name. In Example 4–1, the patterns are a, b, c, and d.
If the pattern matches the domain part of the address, the rewrite rule is applied to the address. A blank space must separate the pattern from the template. For more information about pattern syntax, see Rewrite Rule Patterns and Tags.
Is one of the following. For more information about template syntax, see Rewrite Rule Templates.
UserTemplate%DomainTemplate@ChannelTag[controls] UserTemplate@ChannelTag[controls] UserTemplate%DomainTemplate[controls] UserTemplate@DomainTemplate@ChannelTag[controls] UserTemplate@DomainTemplate@SourceRoute@ChannelTag[controls]
Specifies how the user part of the address is rewritten. Substitution sequences can be used to represent parts of the original address or the results of a database lookup. The substitution sequences are replaced with what they represent to construct the rewritten address. In Example 4–1, the $U substitution sequence is used. For more information, see Template Substitutions and Rewrite Rule Control Sequences.
Specifies how the domain part of the address is rewritten. Like the UserTemplate, the DomainTemplate can contain substitution sequences.
Indicates the channel to which this message is sent. (All channel definitions must include a channel tag as well as a channel name. The channel tag typically appears in rewrite rules, as well as in its channel definition.)
The applicability of a rule can be limited using controls. Some control sequences must appear at the beginning of the rule; other controls must appear at the end of the rule. Some can appear almost anywhere in a rule. For more information about controls, see Template Substitutions and Rewrite Rule Control Sequences.