procmail
[Top] [All Lists]

Re: How to use procmail to forward mail under conditions

1999-05-20 13:24:52
Well, I'll take a stab at this one, even though I've not actually done much of
this kind o' stuff.

1999-05-20-17:21:15 tomers:
if (To == "email1(_at_)host(_dot_)com" )
then {
 add "Misc" field and write orginal "To" to it;/*optional*/
 write "email2(_at_)host(_dot_)com" in "To" ;
 forward message to "email2(_at_)host(_dot_)com" (without saving) ;
}

I think that comes to

        :0
        * ^To: email1(_at_)host(_dot_)com
        {
                :0 fh
                |formail -R To: Misc: -a "To: email2(_at_)host(_dot_)com"

                :0
                ! email2(_at_)host(_dot_)com
                
        }

However, I'm pretty sure this is a case where you urgently should consider
adding a loop-blocker; I'd probably just go:

        :0
        * ^To: email1(_at_)host(_dot_)com
=>      * !^Misc: email2(_at_)host(_dot_)com
        {
                :0 fh
                |formail -R To: Misc: -a "To: email2(_at_)host(_dot_)com"

                :0
                ! email2(_at_)host(_dot_)com
                
        }

I.e. only enter the block if you haven't already bounced this thingie once.
Email forwarding loops get sysadmins mad at you, and that's never a good
thing.

-Bennett