procmail
[Top] [All Lists]

Re: Simple Killfile Recipe?

2002-01-07 06:02:28
* Philip Mak <pmak(_at_)animeglobe(_dot_)com> spake thus:
On Fri, Jan 04, 2002 at 06:54:00PM -0800, Timothy J. Luoma wrote:
Does anyone know where I can find a simple procmail recipe for
killfiling people? 

yes, see below.

I was wondering if there was some stock code I could just drop into
.procmailrc so that it can read a blacklist from a file or something,
though. The way you suggested above works if I just want to block a
few addresses, but if I have a long list of 20 blocks then it gets
ugly and I'm afraid of making a syntax error when I edit .procmailrc

This might seem a bit naive to the more advanced users here, but it
works quite well for me. I use a flat file, with one spammer address on
each line. Positive/negative feedback welcome :-)

I use a scheme where I don't even have to add names to my spammers-list
myself (but I can if I want); it is done automatically by just
forwarding the offending message to myself. Or, I can send myself a
message with "plonk someaddress(_at_)somewhere(_dot_)edu" in the subject line, 
and
that address will be added to the list.

I also have a scheme where I can plonk just the thread, but not the
sender, since on mailing lists it is often more of a problem with all the
_replies to the original spammer_ than the spam itself. But this only
work if people use proper MUA's that leave a "References:" or
"In-Reply-To:" header in when they reply. MUA's that don't should FOAD!

Now, if I receive a mail from a known spammer, that mail will be moved
to my spam folder. In addition to that, we record the "Message-Id:" such
that every mail that refers to this id is regarded spam, without the
sender being marked as a spammer.

You can of course extend this to add more spam-detection rules, but this
simple scheme works so well, I haven't bothered. I'd be delighted to
hear what you think.

LOGFILE=logs/blacklist
VERBOSE=on
:0
* ^To.*stig@(arwen\.)?brautaset\.org
* ^From.*stig@(arwen\.)?brautaset\.org
{
        # add addresses from the subject line to the list of known spammers
        :0
        * ^Subject.*plonk[      ]*\/[^  ].+
        | echo $MATCH >> ~/Mail/SPAMMERS
        
        # just plonk the thread, not the sender
        :0 w
        * ^Subject.*kill
        | formail +1 -ds | formail -x"Message-Id:" >> ~/Mail/SPAM_THREADS
        
        # If I forward spam to myself, sender of the original mail should be
        # blackholed, + the thread will be as well.
        :0 w
        * ^Subject: Fwd:
        * ? formail +1 -ds | formail -cx"Message-Id:" >> ~/Mail/SPAM_THREADS
        | formail +1 -ds | formail -x"From:" -x"Sender:" -x"X-Envelope-Sender:" 
| sed -e 's/.*<\((_dot_)*(_at_)(_dot_)*\)>.*/\1/' >> ~/Mail/SPAMMERS
}

# plonk known spammers with this rule.
LOGFILE=logs/spam
:0
* ? formail -x"From" -x"From:" -x"Sender:" -x"X-Envelope-Sender:" | fgrep -is 
-f ~/Mail/SPAMMERS
{
        :0 hwc
        | formail -cx"Message-Id:" >> ~/Mail/SPAM_THREADS
        :0 ahwc
        | formail -cx"Subject:" | sed -e s/^\ */\"/ -e s/$/\"/ >> 
~/Mail/SPAM_SUBJECTS
        :0 a:
        spam
}

# just plonk thread.
:0
* ? formail -cx"References:" -x"In-Reply-To:" | fgrep -is -f ~/Mail/SPAM_THREADS
{
        :0 hwc:
        | formail -cx"Message-Id:" >> ~/Mail/SPAM_THREADS
        :0 a:
        spam
}


Stig

-- 
brautaset.org
Registered Linux User 107343

``Oh, how I wish `undo' was ported to everyday life.''
_______________________________________________
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>