procmail
[Top] [All Lists]

Re: is this grep is correct?

2000-09-28 01:11:45
At 10:12 2000-09-28 +0300, Vyacheslav Zakharov wrote:

FROM=`${FORMAIL} -z -rt -xTo:`

See countless recent posts saying how you DO NOT put variables in braces - procmail doesn't use them.

Further, this is more concise:

FROM=|$FORMAIL -rtzxTo:

* ? cat ${HOME}/trusted_addresses | grep ${FROM}

spare yourself the cat:

* ? grep -i $FROM $HOME/trusted_addresses

(note the use of the -i flag for case insensitivity)


is there other way to filter a message in case i have some file with some
addresses based on that i'm going to do some actions.

By way of example, I use a similar method for twit filtering (one of many filters in my twit filtration):

# ==========================================================================

# If a SPECIFIC ADDRESS from the twitlist appears anywhere within the
# headers, minus subject, and addressees, toss it.

# Because twit filtering occurs before lists, even those which are filtered
# before spam checking, this allows us to catch morons who post spam or
# other drivel to mailing lists.

:0h
FAILKEY=| ($FORMAIL -ISubject: -ITo: -ICc: -IResent-To: -IResent-Cc: | $MEGAGREP -i -f $TWITLIST)

# If failkey is nonblank, we matched something.
:0
* ! $FAILKEY ?? ^^^^
{
        LOG="SPAM: Match against twitlist [$FAILKEY].$TWITVER"

        :0:
        |gzip -9fc>>$MAILDIR/twits.gz
}

# ==========================================================================

megagrep is a purpose-written utility to efficiently search for a strings from the datafile in the passed text. For all intents and purposes, you can use grep in it's place. However, I use the program because I have lists of spam domains which are hundreds of thousands of lines long, and plain GREP is a memory hog when it hits them (and slow too). megagrep loads them all into a n-ary tree once, and processes the header appropriately - much faster and less of a memory pig -- but it isn't written around supporting regexps (which is fine for my needs).


---
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

 Sean B. Straw / Professional Software Engineering
 Post Box 2395 / San Rafael, CA  94912-2395


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