procmail
[Top] [All Lists]

Re: Rejecting multiple names/subjects at once?

1996-06-10 08:15:25
Is there a way to convert this to a text file that also scans for
'subjects'?  Many of the spams I deal with are best remedied with a
combination of 'subject line', 'user(_at_)site'  and just 'site'.  There
are some sites (videofantasy.com, for ewxample) where no good ever
comes of mail sent from there.

Although your notion of file names is also good because it has a date
stamp right there.  Let me ask you, can these files contain anything?
I mean let's say I want to place a few lines in there explaining why I
put them in the bozo file, or maybe a copy of their post that placed
them there (for future reference and 'proof' of mis-behavior)?

Can this recipe be expanded to include the subject and site only
information?  Or should something new be created.... maybe perl or
something?

You guys are all forgetting that procmail has a fairly efficient egrep
mechanism embedded.  Using a test on a filename is very inefficient by
comparison.  

By using "egrep -f" you can have a file of regular expressions which can
contain bad address patterns.

And, you can do combinations of the two techniques.

The recipes below are examples, and may need adjustment for your usage.

    FROM=`formail -rtzxTo:`

    # In this recipe, you can check a bunch of addresses you don't like
    # at once
    :0
    * FROM ?? 
(Someguy(_at_)address(_dot_)foo|someotheraddress(_at_)badaddr(_dot_)foo|addr2(_at_)bad(_dot_)foo)
    { BOUNCE=1 }

    # Set BADADDRS to the filename which has the regular expressions for
    # addresses we don't like
    BADADDRS=badaddrs

    # This recipe filters FROM through the badaddrs file, if egrep succeeds,
    # then we don't want this mail, and we'll bounce it
    :0E
    * ? echo "$FROM" | egrep -f $BADADDRS
    { BOUNCE=1 }

    # Okay, do combinations of addresses and subjects. 
    # NB: Capitalization doesn't matter.

    # Any of these subjects, regardless of whom, will bounce
    :0E
    * Subject:.*(Free Advertising|X-Rated Pictures|Live Nude Models)
    { BOUNCE=1 }

    # These combinations will cause bounces...
    :0E
    * FROM ?? (Vice-)?President(_at_)whitehouse(_dot_)gov
    * Subject:.*Vote For
    { BOUNCE=1 }

    :0E
    * FROM ?? (Newt|Gingrich)@congress.gov
    * Subject:.*Vote For
    { BOUNCE=1 }

    :0E
    * FROM ?? (Larry King|Rush Limbaugh)
    * Subject:.*Politics
    { BOUNCE=1 }


    # After all the recipes.. check the BOUNCE flag

    :0
    * BOUNCE ?? .
    {
        SUBJ=`formail -xzSubject:`
        # Form a reply in the headers
        :0 fh
        | formail -rt -I"From:    Postmaster" \
                      -I"Subject: Re: $SUBJ"

        # Replace the body of the message with our canned message
        :0 fb
        | cat explanation ; cat -

        # Now send the reply
        :0
        | -oi -t

        HOST=_stop_             # and stop here
    }

_______________________________________________________________
Alan Stebbens      <stebbens(_at_)sgi(_dot_)com>      (415) 933-6437
Interactive Digital Systems (IDS), Silicon Graphics, Inc. (SGI)
M/S:9L991, 2011 N. Shoreline Blvd., Mountain View, CA 94043