procmail
[Top] [All Lists]

Re: implementing a kind of killfile ?

2000-02-24 00:11:16
On Thu, 24 Feb 2000 01:13:42 +0100, Sebastian Helms
<sebastian(_at_)helms(_dot_)sh> wrote:
I am trying to implement a kind of killfile, which I can "fill" >:->
from within mutt. I thought about piping the message through a script
which extract the author and appends the email to a file.

Here's what I'm using for that.

    FROM=`formail -rtzxTo:`  # Not good for lists with Resent- or Reply-To

    :0
    * ? fgrep -qxis "$FROM" $HOME/procmail/bozo
    {
        LOG=" trashed: $FROM is in bozo file
 "
        :0:
        scratch/bozo
    }

And here's the corresponding script to add a new bozo:

#!/bin/sh
#
# Feed this script a message from a bozo on standard input, with the
#  name of the killfile as the first command-line argument to the script

file="$1"

if co -q -l "$file"; then
        formail -IResent- -rtzxTo: >>"$file"
        exec ci -q -u "$file" </dev/null
else
        echo "$0: Could not get a lock on $file" >&2
        exit 1
fi

The commands "ci" and "co" are RCS source version control commands. I
haven't bothered to implement locking between Procmail and the
killfile script; if a message manages to slip through while the
address is being added, it's not a big deal. (In other situations, you
should worry about this, but I think jumping through extra hoops here
is not worth the trouble.)

I have an Emacs keybinding in VM (the mail reading mode I use) which
prompts for which bozo file to use, and then adds the author of the
currently selected message in one fell swoop.

I'll have to add that the bozo file is practically empty. I mainly use
it when there's a mail loop or other technical problem I want to
quench the local effects of. And yes, the filtered messages are filed
for reference and diagnostics, although the file is on a temporary
disk where system administration removes files you haven't touched in
a week. (A nightly cron job moves yesterday's file to a different name
so I don't just keep on appending to the same file forever.)

For mailing lists, I have a separate bozo file specific to each list,
and a corresponding Procmail recipe for each. Those listed people will
still be able to mail me privately and I don't want to block that; I
just don't want to see their posts to a particular list.

(Some people are on a lot of the same lists I'm on, and have very
little to contribute to any of them, but I've just added them to the
bozo file for each list separately when I've gotten particularly tired
of reading their messages.)

As indicated by the comment, I have to use a different formail
incantation to set the FROM variable for certain mailing lists.

Well, why not just include another example:

    :0
    * ^From 
majordom-abusespamtools-out-owner-reriksso=cc\(_dot_)helsinki\(_dot_)fi(_at_)\
            ([^<>        @.]+\.)*iecc\.com
    {
        FROM=`formail -IReply- -rtzxTo:`  # bl@@dy reply-to: list header

        :0
        * ? fgrep -qxis "$FROM" $HOME/procmail/spamtools-bozo
        {
            LOG=" trashed: $FROM is in the spamtools-bozo file
 "
            :0:
            scratch/spamtools-bozo
        }

        :0:
        inbox/spamtools
    }

There's a bit of duplication with recipes similar to this one for each
list I'm on (for which I actually want to have a bozo filter) but it's
not something I'm worrying a lot about yet. (I have bozo filtering for
six of the lists I subscribe to, and a whitelist called nobozo for
people whose mail won't need to go through spam filtering etc.)

Is something like this possible ? Or is it better to just write the
recipes along with the email addresses and let procmail source that
file ?

I like the text file approach because it's easier to maintain, but it
would probably operate more efficiently if you somehow transformed
those entries into Procmail recipes. You don't have to do that by
hand, just construct a simple script and a Makefile to go with it (and
remember to run make when you've updated the simple text file :-)

Incidentally, links to some earlier messages about this topic are
available at <http://www.iki.fi/era/procmail/links.html> in the
"pearls" section. (ISTR it talks about having "spammers" in a file but
it generalizes nicely to having other sorts of addresses in files.)

A quick note about the social side of killfiling: There shouldn't be
one. Twit filtering is entirely a business between yourself and your
mail spool, and it's usually rude, arrogant, and above all pointless
to let people know you're using a bozo filter (not to mention let
somebody know they're in it).

/* era */

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

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