Channel match force truncation rewrite

From Messaging Server Technical Reference Wiki
Jump to: navigation, search


Channel match force truncation rewrite, $1~

The special-purpose $1~ rewrite rule control sequence is normally used in conjunction with the domain_failure MTA option.

The $1~ control sequence modifies the effect of channel matching checks, such as the $C, $Q, $M, and $N channel match checks. Normally such checks either succeed, in which case the rewrite rule is used, or fail, in which case it is as if the rewrite rule never even matched and the rewrite rule is not used at all for the address in question. The $1~ control sequence is used when it is desired to instead have the rewrite rule always be used, but with a different right hand side depending upon whether the initial channel match succeeded or failed. That is, the $1~ control sequence overrides the original channel match results (forces a channel match success state), and then either truncates the rewrite rule template (if the original channel match check failed), or allows additional material to be suffixed to the rewrite rule template (if the original channel match check succeeded).

For instance, given channel definitions such as


tcp_local smtp mx ...rest-of-keywords... 
tcp-daemon 
 
tcp_domainrelay smtp mx ...rest-of-keywords... 
tcp-daemon-domainrelay 

then a rewrite rule such as


domain.com      $U%domain.com@tcp-daemon$Mtcp_local$1~-domainrelay 

means that when the tcp_local channel is rewriting a domain.com address, then the effective template used will be


$U%domain.com@tcp-daemon-domainrelay 

whereas when any other channel is rewriting a domain.com address, then the effective template used will be


$U%domain.com@tcp-daemon 

That is, messages coming in the tcp_local channel addressed to domain.com will be routed out the tcp_domainrelay channel, whereas messages coming in from any non-tcp_local channel addressed to domain.com will be routed out the tcp_local channel.

The $1~ control sequence is typically used in the value of the domain_failure MTA option; see the discussion of that option which includes another example of use of $1~.


See also: