Sun Java System Messaging Server 6.3 Administration Guide

11.2 Rewrite Rule Structure

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.
!   $U@a-host   $U@b-host   $U%c@b-daemon   $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


Indicates the string to search for in the domain name. In Table 11–3 the patterns are,,, and

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 11.3 Rewrite Rule Patterns and Tags


is one of the following:



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 11.6 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 11.6 Template Substitutions and Rewrite Rule Control Sequences

For more information about template syntax, see 11.4 Rewrite Rule Templates