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. The example below shows 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.com $U@a-host b.org $U@b-host c.edu $U%c@b-daemon d.com $U%d@a-daemon ! Begin channel definitions |
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:
pattern template |
pattern
Indicates the string to search for in the domain name. In Table 11–3 the patterns are a.com, b.org, c.edu, and d.com.
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
template
is one of the following:
UserTemplate%DomainTemplate@ChannelTag[controls] UserTemplate@ChannelTag[controls] UserTemplate%DomainTemplate[controls] UserTemplate@DomainTemplate@ChannelTag[controls] UserTemplate@DomainTemplate@SourceRoute@ChannelTag[controls]
where
UserTemplate 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 Table 11–4, the $U substitution sequence is used. For more information, see Template Substitutions and Rewrite Rule Control Sequences
DomainTemplate specifies how the domain part of the address is rewritten. Like the UserTemplate, the DomainTemplate can contain substitution sequences.
ChannelTag 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.)
controls. 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. For more information about controls, see Template Substitutions and Rewrite Rule Control Sequences
For more information about template syntax, see Rewrite Rule Templates