PMDF System Manager's Guide


Previous Contents Index

2.2.6 Template Substitutions and Rewrite Rule Control Sequences

Substitutions are used to substitute into the rewritten address a character string the value of which is determined by the particular substitution sequence used. For instance in the template


$U@example.com 
the $U is a substitution sequence. It causes the username portion of the address being rewritten to be substituted into the output of the template. Thus, if jdoe@vax1.example.com was being rewritten by this template, the resulting output would be jdoe@example.com, the $U substituting in the username portion, jdoe, of the original address.

Special control sequences may also appear in rewrite rule templates. These sequences impose additional conditions to the applicability of a given rewrite rule: not only must the pattern portion of the rewrite rule match the host/domain specification being examined, but other aspects of the address being rewritten must meet conditions set by the control sequence or sequences. For instance, the $E control sequence requires that the address being rewritten be an envelope address while the $F sequence requires that it be a forward pointing address. Thus, the rewrite rule


example.com    $U@example.com$E$F 
will only apply to (i.e., only rewrite) envelope To: addresses of the form user@example.com. If a domain/host specification matches the pattern portion of a rewrite rule but doesn't meet all of the criteria imposed by control sequences in the rule's template, then the rewrite rule fails and the rewriter continues to look for other applicable rules. This makes possible sets of rewrite rules such as


example.com    $U%example.com@directory-daemon 
example.com    $U@example.com$Ndirectory 
which will result in messages to user@example.com being passed to the directory channel. However, should the directory channel rewrite a message with the address user@example.com, that message will not again pass through the directory channel. This then allows all mail to user@example.com to pass through the directory channel and for the directory channel to emit mail to that address without causing a mail loop.

A summary of template substitutions and control sequences is presented in Table 2-3.

Table 2-3 Summary of Template Substitutions and Control Sequences
Substitution sequence Section Substitutes
$D 2.2.6.2 Portion of domain specification that matched
$H 2.2.6.2 Unmatched portion of host/domain specification; left of dot in pattern
$L 2.2.6.2 Unmatched portion of domain literal; right of dot in pattern literal
$U 2.2.6.1 Username from original address
$0U 2.2.6.1 Local part (username) from original address, minus any subaddress
$1U 2.2.6.1 Subaddress, if any, from local part (username) of original address
$$ 2.2.6.3 Inserts a dollar sign (literal)
$% 2.2.6.3 Inserts a percent sign (literal)
$@ 2.2.6.3 Inserts an at sign (literal)
$\ 2.2.5.4 Force substituted material to lowercase
$^ 2.2.5.4 Force substituted material to uppercase
$_ 2.2.5.4 Use original case
$W 2.2.6.9 Substitutes in a random, unique string
$]...[ 2.2.6.4 LDAP search URL lookup
$( text) 2.2.6.5 General database substitution; rule fails if lookup fails
${...} 2.2.6.6 Apply specified mapping to supplied string
$[...] 2.2.6.7 Invoke customer supplied routine; substitute in result
$&n 2.2.6.8 nth part of unmatched (or wildcarded) host as counting from left to right starting from 0
$! n 2.2.6.8 nth part of unmatched (wildcarded) host as counted from right to left starting from 0
$* n 2.2.6.8 nth part of matching pattern as counting from left to right starting from 0
$# n 2.2.6.8 nth part of matching pattern as counted from right to left starting from 0
$ nD 2.2.6.2 Portion of domain specification that matched, preserving from the nth leftmost part starting from 0
$ nH 2.2.6.2 Portion of host/domain specification that didn't match, preserving from the nth leftmost part starting from 0
Control sequence Section Effect on rewrite rule
$E 2.2.6.12 Apply only to envelope addresses
$B 2.2.6.12 Apply only to header/body addresses
$F 2.2.6.12 Apply only to forward-directed ( e.g., To:) addresses
$R 2.2.6.12 Apply only to backwards-directed ( e.g., From:) addresses
$M channel 2.2.6.10 Apply only if channel channel is rewriting the address
$N channel 2.2.6.10 Fail if channel channel is rewriting the address
$Q channel 2.2.6.11 Apply if sending to channel channel
$C channel 2.2.6.11 Fail if sending to channel channel
$S 2.2.6.13 Apply if host is from a source route
$A 2.2.6.13 Apply if host is to the right of the at sign
$P 2.2.6.13 Apply if host is to the right of a percent sign
$X 2.2.6.13 Apply if host is to the left of an exclamation point
$T newtag 2.2.6.14 Set the rewrite rule tag to newtag
$ n? errmsg 2.2.6.15 If rewriting fails return errmsg instead of the default error message


Previous Next Contents Index