This section shows how to add a new rewrite rule to prevent a message loop from happening if the program is doing intermediate processing that leaves the envelope recipient addresses unchanged. Otherwise, the channel would just enqueue the mail back to itself.
For discussion purposes, suppose that the channel is to provide intermediate processing for mail addressed to user@siroe.com. Further, the imta.cnf file has the following rewrite rule for siroe.com:
siroe.com $U@siroe.com
For example, as shown in the code example that follows, assume that the intermediate processing channel’s name is “xloop_test.” Near the bottom of the imta.cnf file with other channel definitions, you would see the following definition:
xloop_test x-looptest-daemon |
Then, as shown in the following example, a new rewrite rule for siroe.com needs to be added to the top of the imta.cnf file:
siroe.com $U%siroe.com@x-looptest-daemon$Nxloop_test siroe.com $U@siroe.com |
The new rewrite rule causes the following to happen:
When a new inbound or outbound message for user@siroe.com is enqueued to the xloop_text channel, it processes the message and re-enqueues it to user@siroe.com.
In the new rewrite rule, $N says that the first (new) rewrite rule is to be ignored when the xloop_test channel itself enqueues a message.
Therefore, after the xloop_test channel does its processing and re-enqueues the message to user@siroe.com, the first (new) rewrite rule is ignored and the second (old) rule is then applied, causing the message to be routed as it would have been before the xloop_test channel was added to the MTA.