procmail
[Top] [All Lists]

Re: If then else

2000-03-25 21:34:04
On Thu, Mar 23, 2000 at 10:32:28AM -0500, Bruce S. Marshall wrote
If match in Good list, continue with other recipes

  Else try for a match in the SPAM list


I have the following:

:0 Hc:
* ? fgrep -i -0 -f goodlist
good    <---  I really want a NOP here so I will replace this with
/dev/null
 Yikes, your good email would be wiped out.  Replace "/dev/null"
with "$DEFAULT" (without the quotes), to send to your default inbox.
I don't dev/null even stuff that I strongly suspect to be spam.  No
filter is perfect.  I redirect to another folder.

I want the spamlist test to be bypassed if the match occurs in
goodlist.  Right now, it appears the spamlist test is never done.

Any suggestions?

  Procmail doesn't have an explicit if-then-else, but it has a reasonable
facsimile.  Processing continues until either...
1) the email is "delivered" or
2) the end of the recipe is reached, email goes to default inbox

  The usual way to do it is to have the "whitelist" at the top, followed
by the "blacklist".  If neither list flags a message it defaults to your
inbox.  Procmail treats multiple conditions as AND's.  If you want to
put multiple conditions in a recipe, with OR logic, scoring is easier to
follow than "double negative" conditions.  Here's an example...

 #
 # Start off with the whitelist.  Emails that you accept unconditionally
 # $DEFAULT is procmail's way of saying "your regular mailbox".  Award
 # 1 point for any match.  If the sum is positive then procmail will
 # deliver to the indicated mailbox.
 #
 :0
 * 1^1 ^From: 
.*(mom+dad(_at_)home(_dot_)com|boss(_at_)work(_dot_)com|girfriend(_at_)someISP(_dot_)au)
 * 1^1 ^X-Loop: procmail
 $DEFAULT

 #
 # If the email matched an item on the whitelist, it should get delivered
 # and never see this recipe.
 # I know that the "protecting braces" should *NOT* be necessary.  However,
 # if your ISP runs low on space, and delivery to your mailbox fails,
 # procmail will continue processing.  Stuff that should never be flagged
 # as spam will be tested by the following recipes.  This will hurt when
 # you whitelist a friend at an ISP that you otherwise block.  The E
 # around the rest of the recipes will avoid the test if an email matches
 # a whitelist criterion, but runs into a full mailbox.
 #
 :0E
{
#
# The following recipe diverts all email from southeast Asia both by
# country code and IP block (202.xxx.xxx.xxx and 203.xxx.xxx.xxx) as
# well as an individual and an entire ISP.  This example illustrates
# whitelisting one account (mom+dad(_at_)home(_dot_)com) at an ISP while 
blocking
# everybody else at that ISP.
#
 :0
 * 1^1 ^Received: from .*(\.au|\.cn|\.hk|\.tw|\.home\.com|\
20[23]\.[0-9]+\.[0-9]+\.[0-9]+)
 * 1^1 ^From: (_dot_)*flamer(_at_)flamefest(_dot_)com
 junkmail

 # Other recipes go here.

}
 #
 # procamail will attempt to deliver to your default inbox any email
 # that gets past the end of the recipes without being delvered
 # elsewhere.
 #
-- 
Walter Dnes <waltdnes(_at_)waltdnes(_dot_)org> SpamDunk Project procmail 
spamfilter
at http://www.waltdnes.org   This message coming to you in living Linux.

<Prev in Thread] Current Thread [Next in Thread>
  • If then else, Bruce S. Marshall
    • Re: If then else, Walter Dnes <=