procmail
[Top] [All Lists]

Re: Simple bounce for a specific address

2001-01-16 12:11:13
Chris Green wrote:
I want to bounce mail for one specific address, I have a lot of mail
which gets forwarded to my work E-Mail and one specific form of one
of the addresses I want to bounce.

Would a formula something like the following work? :-

    :0
    * ^TOxxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc
    | $SENDMAIL -oi -t

Sorry, no.  Absent loop-trapping operations, the above recipe will
bring the just wrath of many administrators, including your own, onto
your head.  Here's what I mean.  Mail addressed to 
xxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc
arrives in your mailbox.  It matches the condition in your above
recipe and gets forwarded to sendmail.  Because of the 't' flag,
sendmail will send it to all the addresses it finds in headers "To:"
and "cc:".  It will then arrive in your mailbox again, match the
conditions, and be fed to sendmail, which will send it to all the
addresses it finds... it will then arrive in your mailbox again....

Not only this, but suppose the mail was addressed as:

    To: xxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc
    cc: ex-friend(_at_)ex-friends(_dot_)isp(_dot_)com

Each time the mail arrives in your mailbox and is fed to sendmail, a
copy will also be sent to ex-friend(_at_)ex-friends(_dot_)isp(_dot_)com .  This 
person
will quickly become an ex-friend after receiving however many copies
of the email.

The other, fundamental, thing is that you're not bouncing it, but
re-sending it to whoever the mail was addressed to in the first place.

If you want the mail to go back to the sender, then something like
this might work for you.  It is UNTESTED so you should test it
yourself, etc.

    :0
    * ! ^FROM_DAEMON
    * ! ^X-Loop: *xxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc
    * ^TOxxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc
    {
        :0 fhW
        | formail -A "X-Loop: xxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc"

        EXITCODE=67             # EX_NOUSER, see /usr/include/sysexits.h
        HOST=foo.bar.invalid.   # illegal hostname, should stop
                                # processing immediately 
    }

The above ought to bounce mail back to the sender with "User unknown".

Alternately, you can modify the header and send the original content
back as...

    :0
    * ! ^FROM_DAEMON
    * ! ^X-Loop: *xxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc
    * ^TOxxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc
    {
        # modify the header only 
        :0 fhw
        | formail -rt -A "X-Loop: xxxxx(_at_)aaa(_dot_)bbb(_dot_)ccc" -A 
"Precedence: junk"

        :0 a
        ! -t

        # If we get here, there was an error above!

        EXITCODE=67             # EX_NOUSER
        HOST=foo.bar.invalid.   # illegal hostname, should stop
                                # processing immediately 
    }

Please take a look at "man procmailex" for example of X-Loop, and also
http://www.procmail.org/jari/pm-tips.html ; see 6.14, (near end of)
9.19, (near end of) 18.7, 21.3

hth
-- 
Neither I nor my employer will accept any liability for any problems
or consequential loss caused by relying on this information.  Sorry.
Collin Park                         Not a statement of my employer.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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