Sun Java System Messaging Server 6 2005Q4 Administration Reference

Template Substitutions and Rewrite Rule Control Sequences

Substitutions are used to rewrite user names or addresses by inserting a character string into the rewritten address, the value of which is determined by the particular substitution sequence used.

Control 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 or domain specification being examined, but other aspects of the address being rewritten must meet conditions set by the control sequence or sequences.

If a domain or host specification matches the pattern portion of a rewrite rule but doesn’t meet all of the criteria imposed by a control sequences in the rule’s template, then the rewrite rule fails and the rewriter continues to look for other applicable rules.

Table 4–5 summarizes the template substitutions and control sequences.

Table 4–5 Summary of Template Substitutions and Control Sequences

Substitution Sequence  

Substitutes  

$D

Portion of domain specification that matched. 

$H

Unmatched portion of host/domain specification; left of dot in pattern. 

$L

Unmatched portion of domain literal; right of dot in pattern literal. 

$U

User name from original address. 

$0U

Local part (username) from original address, minus any subaddress. 

$1U

Subaddress, if any, from local part (username) of original address. 

$$

Inserts a literal dollar sign ($). 

$%

Inserts a literal percent sign (%). 

$@

Inserts a literal at sign (@). 

$\

Forces material to lowercase. 

$^

Forces material to uppercase. 

$_

Uses original case. 

$W

Substitutes in a random, unique string. 

$]...[

LDAP search URL lookup. 

$(text)

General database substitution; rule fails if lookup fails. 

${...}

Applies specified mapping to supplied string. 

$[...]

Invoke customer supplied routine; substitute in result. 

$&n

The nth part of unmatched (or wildcarded) host, counting from left to right, starting from 0. 

$!n

The nth part of unmatched (or wildcarded) host, as counted from right to left, starting from 0. 

$*n

The nth part of matching pattern, counting from left to right, starting from 0. 

$#n

The nth part of matching pattern, counted from right to left, starting from 0. 

$nD

Portion of domain specification that matched, preserving from the nth leftmost part starting from 0 

$nH

Portion of host/domain specification that didn't match, preserving from the nth leftmost part starting from 0 

Control Sequence  

Effect on Rewrite Rule 

$1M

Apply only if the channel is an internal reprocessing channel. 

$1N

Apply only if the channel is not an internal reprocessing channel. 

$1~

Perform any pending channel match checks. If the checks fail, successfully terminate processing of the current rewrite rule template. 

$A

Apply if host is to the right of the at sign 

$B

Apply only to header/body addresses 

$C channel

Fail if sending to channel

$E

Apply only to envelope addresses 

$F

Apply only to forward-directed (e.g., To:) addresses 

$M channel

Apply only if channel is rewriting the address

$Nchannel

Fail if channel is rewriting the address

$P

Apply if host is to the right of a percent sign 

$Q channel

Apply if sending to channel

$R

Apply only to backwards-directed (e.g., From:) addresses 

$S

Apply if host is from a source route 

$Tnewtag

Set the rewrite rule tag to newtag 

$Vhost

Fail if the host name is not defined in the LDAP directory (either in the DC tree or as a virtual domain). If the LDAP search times out, the remainder of the rewrite pattern from directly after the character following the host name is replaced with the MTA option string DOMAIN_FAILURE.

$X

Apply if host is to the left of an exclamation point 

$Zhost

Fail if the host name is defined in the LDAP directory (either in the DC tree or as a virtual domain). If the LDAP search times out, the remainder of the rewrite pattern from directly after the character following the host name is replaced with the MTA option string DOMAIN_FAILURE.

$?errmsg

If rewriting fails, return errmsg instead of the default error message. The error message must be in US ASCII.

$number?errmsg

If rewriting fails, return errmsg instead of the default error message, and set the SMTP extended error code to a.b.c:

  • a is number/ 1000000 (the first digit)

  • b is (number/1000) remainder 1000 (the value of the digits 2 through 4)

  • c is number remainder 1000 (the value of the last three digits.

    The following example sets the error code to 3.45.89:

    $3045089?the snark is a boojum

For more information on substitutions, refer to the Sun Java System Messaging Server 6 2005Q4 Administration Guide.