wesley--- via Postfix-users wrote:
> may I know that, what's the mechanism for postfix to stop mail
> delivery looping?
>
> for example, u...@foo.com forwards to u...@bar.com, and u...@bar.com
> forwards back to u...@foo.com, this will be a loop.
>
> so how postfix find and stop this behavior?

Most people would not use Postfix itself for this purpose.  It's not
really the job of Postfix to do this type of mail filtering.  Most
people would use a mail processing tool such as procmail or sieve to
do this.  I have always used procmail.  Let me copy-paste in a snippet
from the procmail examples man page that addresses exactly your question.

    man 5 procmailex

       Suppose you have two accounts, you use both accounts regularly, but
       they are in very distinct places (i.e., you can only read mail that
       arrived at either one of the accounts).  You would like to forward mail
       arriving at account one to account two, and the other way around.  The
       first thing that comes to mind is using .forward files at both sites;
       this won't work of course, since you will be creating a mail loop.
       This mail loop can be avoided by inserting the following recipe in
       front of all other recipes in the $HOME/.procmailrc files on both
       sites.  If you make sure that you add the same X-Loop: field at both
       sites, mail can now safely be forwarded to the other account from
       either of them.

              :0 c
              * !^X-Loop: yourn...@your.main.mail.address
              | formail -A "X-Loop: yourn...@your.main.mail.address" | \
                 $SENDMAIL -oi yourname@the.other.account

It looks for the presence of the X-Loop header and if the entire
header line matches then it does NOT forward the message (it's already
been seen on the other site) and therefore avoids creating the mail
loop problem.

Please remember that procmail is a very old tool that dates from
earlier much kinder and gentler days.  Mail forwarding now has new
hazards.  Hazards which you seem to be navigating regardless of
procmail anyway.  I say this to guard against the many arguments that
might be posted saying that forwarding is now to be avoided, they hate
me, they hate my dog, and so on. :-)

I will help with that by mentioning that there are other tools as well
which can be used to synchronize mailboxes between two sites that does
not use mail forwarding.  Such as offlineimap3, isync, maildirsync,
and other such utilities.  It's a different way to do things.

Bob
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to