procmail
[Top] [All Lists]

Re: Running a script from procmail

2006-09-30 03:26:46
On Sat, Sep 30, 2006 at 06:28:54AM +0100, Steve A wrote:

Professional Software Engineering wrote:

:0
* $? formail -x"To:" -x"Cc:" | fgrep -i -w -f $BLACKLIST
{
         # we matched something
         :0fwh
         | formail -A"X-YourCustomHeader: somevalue"
}


Well, this seems to work.

- The fudging with awk is because I only keep a list of the user part of 
the addresses (as they're all to my own domain).

- I've done some tests too, and the X-Original-To header is always 
written even if it's for multiple recipients, so that's handy too!

Yes, it is mail-transfer-agent dependent.

- There is a possible slight anomoly in the log... (see after recipe), 
that makes me wonder if/how/why it might be testing the same condition 
twice.

:0
* ^X-Original-To: (_dot_)*(_at_)mydomain(_dot_)com
{
         :0
         * $? formail -x"X-Original-To:" | \
                 awk -F@ '{sub(/ /,\"\");print \$1}' | \
                 fgrep -i -x -f $RCPT_BLACKLIST
         blacklist
}

If you're always ever just going to use X-Original-To:, you
don't need formail or grep at all. Just use procmail:


    :0
    * ^X-Original-To: \/[^(_at_)]+
    * $? echo $MATCH | fgrep -i -x -f $RCPT_BLACKLIST
    blacklist


Dallman

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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