procmail
[Top] [All Lists]

Re: How to stop mail loop

2000-03-14 18:40:17
At 16:52 2000-03-14 -0800, Ron 'The InSaNe One' Rosson wrote:
I am having a small problem.. I have a user who has a domain. Our
domains are handled by a virtusertable like so:

        user(_at_)domain(_dot_)com         bob
        user1(_at_)domain(_dot_)com        dave
        @domain.com             jeff

Suggestion: if you're already doing sendmail configs for him, and if he's not using procmail already, why not just create a delivery alias?

(see man aliases)

I think the way to accomplish this with virtual hosts is to put a entry in virtusertable:

        all(_at_)domain(_dot_)com          domain.com-all

and in aliases.txt:

        domain.com-all          bob,dave,jeff

Should work.

[snip - whatever]

:0
* ^To:(_dot_)*all(_at_)domain(_dot_)com
! jeff,bob,dave

This RECIPE seems to cause a mail loop.

Uhm, duh?

Jeff's mail come's RIGHT BACK INTO his own mailbox, and gets processed by this recipe. The TO: line STILL contains all(_at_)domain(_dot_)com, and thus causes re-delivery.

Over and over and over.  To the annoyance of the other two users as well.

Fix:  don't mail to Jeff:

:0c
* ^To:(_dot_)*all(_at_)domain(_dot_)com
!bob,dave

the c will make the rule run against a copy (which is delivered to the other two users), and his own copy of the message (the original), continues to be filtered by the remaining recipes in his own file. Assuming there's no other rules, that means the message goes right into his mail spool.

Another way to avoid the mail loop is to modify the message with an X-Loop header, and check to make sure that it isn't present:

:0
* ^To: *all(_at_)domain(_dot_)com
* ! ^X-Loop: all(_at_)domain(_dot_)com
{
        # add a header - f is FILTER
        :0f
        | formail -A "X-Loop: all(_at_)domain(_dot_)com"

        # forward it (with the extra header).  the a flag isn't normally
        # necessary, but ensures that the above rule must have SUCCESSFULLY
        # completed before this takes place - thus hopefully sparing you from
        # grief if your formail gets trampled one day.
        :0a
        !jeff,bob,dave
}

The above is untested, but should work.

When a message first comes in which matches the address, but doesn't have the loop header, the additional header is added and the message is forwarded. One copy of that will reappear in Jeff's mailbox -- but with the X-Loop header which we specifically check for and DON'T forward this copy if it is present.

(BTW, call(_at_)domain(_dot_)com, small(_at_)domain(_dot_)com, etc WILL match 
this address regexp)


---
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

 Sean B. Straw / Professional Software Engineering
 Post Box 2395 / San Rafael, CA  94912-2395

<Prev in Thread] Current Thread [Next in Thread>