procmail
[Top] [All Lists]

Re: filter mail using .aliases file

2004-06-08 13:13:18
On Tue, 08 Jun 2004 23:16:46 +1000, Troy Piggins <troy(_at_)piggo(_dot_)com> 
wrote:
* LuKreme <kremels(_at_)kreme(_dot_)com> :

:0 h
CLEANFROM=|formail -IReply-To: -rtzxTo:

WHITELIST=$HOME/.aliases

:0
*  * $ ? formail -IReply-To: -rtzxTo: | egrep -w \"$CLEANFROM\"
white

might work.

Thought I would post this solution from William Park in
comp.mail.misc :

:0
* ^From:.*\/[A-Za-z0-9_(_dot_)+-]+(_at_)[A-Za-z0-9_(_dot_)+-]+
* ? grep -i "$MATCH" ~/.aliases
white

Seems essentially the same except you are not harnessing the power of
formail to extract the FROM.  That $match would fail, for example, on
one of my contacts headers:

From: "John(_at_)work" <jsmith(_at_)domain(_dot_)tld>

(name changed to protect the somewhat willfully clueless :)

Seems simple.  I actually had something more complicated like :

WHITELIST=$HOME/.aliases
CLEAN_FROM=`formail -x "From:" -x "From" -x "Sender:" | sed -e
"s/^.*[^A-Za-z0-9_.+-]\([A-Za-z0-9_(_dot_)+-]*(_at_)\)/\1/" -e
"s/\(@[A-Za-z0-9_.+-]*\)[^A-Za-z0-9_.+-].*$/\1/"`

:0:
* ^TO_(troy)@(piggo.com)
* ? cat $WHITELIST | fgrep -i -is $CLEAN_FROM
white

This also worked, but not as elegant.

I think Sean's solution (which is what I posted above, basically)
strikes the right balance of utilizing the tools you have at hand
without adding needless complexity.

_______________________________________________
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>