procmail
[Top] [All Lists]

Re: Mail forwarding question.

1998-01-02 21:11:57
On Fri, 2 Jan 1998, Sanjay Wattal wrote:
Hi all
I've just started using procmail and I think it's a great tool.
Could some guru please help me figure out how to:
1. forward a mail: eg if Subject contains "humor", forward the mail
   to jokes(_at_)list

I'm not one of the gurus, just someone who wants to learn. This would do
it, but if you're receiving the list that your sending this to, you'll
create a mail loop. (Bad thing to do!) 

        :0
        * ^Subject:.*\<humor\>
        ! jokes(_at_)list

So to prevent that, use formail to modify the outgoing header, and use a
condition to prevent mail bearing the X-Loop field from being forwarded. 
You'll also need to make sure the path to formail is explicit in your PATH
setting in .procmailrc.

        :0w
        * ^Subject:.*\<humor\>
        * ! ^X-Loop:.*\<sanjayw\>
        | formail -A"X-Loop: sanjayw" | $SENDMAIL -oielm jokes(_at_)list

Keep in mind that these will both forward ANY mail containing "humor" in
the subject.

2. delete a mail: eg if Subject contains "flame", delete the mail.
Not hard.

        :0
        * ^Subject:.*\<flame\>
        /dev/null

This will drop ANY mail containing the word "flame" in the subject. 

I read the FAQ and READMEs, but couldnt get any hints.

Most of what you need is in the manpages "procmail", "procmailrc",
"procmailex", and "egrep" or "grep". 

David Hunt

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