Channel match force truncation rewrite

Channel match force truncation rewrite,
The special-purpose $1~ rewrite rule control sequence is normally used in conjunction with the    MTA option.

The  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   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  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  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  channel addressed to  domain.com will be routed out the   channel, whereas  messages coming in from any non-  channel addressed to  domain.com will be routed out the   channel.

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

See also:
 * domain_failure MTA Option
 * Source channel-specific rewrites
 * Destination channel-specific rewrites
 * Rewrite rule template substitutions and control sequences