procmail
[Top] [All Lists]

Procmail Spam Filtering

2001-12-31 03:20:11
Hi folks,

This is my first posting to this mailing list so please be kind! 8-)

I'm using procmail in conjunction with SpamAssassin to filter out as
much spam and other rubbish as possible.  I've had some success, but
due to my small head being full already, I'm finding it difficult to grasp the 
intricacies of procmail!

(Spamassassin is at http://spamassassin.taint.org)

I'm hoping it's ok for me to post portions of my procmailrc here for
comment by the Wizards.  I know there are some really awful mistakes
in here - and I suspect they're currently bad enough to prevent this
procmailrc from working properly!

Much of the code has been lifted from elsewhere - I'm just not smart
enough to have written it myself!

With Spamassassin a "-r" flag reports the e-mail as spam and a "-p"
queries the database to check if it is.

--- BEGIN
VERBOSE=no
MAILDIR=/var/spool/mail
LOGABSTRACT=
LOGFILE=/var/log/procmail.log
PATH="/usr/bin:/usr/sbin:/bin:$PATH"
SHELL=/bin/sh
SENDMAIL = "sendmail -oi -t"
FORMAIL = "/usr/bin/formail"
LOG="--- Logging ${LOGFILE} for {$LOGNAME},"
XLOOP = "X-Loop: $LOGNAME(_at_)$HOST"
TXT_NO_HTML = /etc/procmail/reject-message.txt
REJECT = /etc/procmail/return.txt
NL = "
            "
LOCKFILE

## Make a backup & keep the last 32 emails 
:0 c
backup

:0 ic
| cd backup && rm -f dummy `ls -t msg.* | sed -e 1,32d`
####

LOGABSTRACT=all

## 5% rule for BIG5 character set##
## I don't know anyone who would send me BIG5 stuff and every bit I've
## ever received has been spam . It's unsolicited and therefore
## reportable
:0BD
* -1^1 .
*  2^1 =[0-9A-F][0-9A-F]
* 20^1 [ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿]
* 20^1 [ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß]
* 20^1 [àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ]
* 20^1 =[A-F][0-9A-F]
| spamassassin -r
####

## spam reporting
## these are my bait addresses, and addresses that are contaminated
## and already receive too much spam
:0 W
*^TO_\ .*(spamhere|spam|nospam|spammer|porn|addme|cokoso62)@
| spamassassin -r
####

## reject HTML
## we don't want no steekin' HTML so reject it but explain why
:0fh
* ! ^FROM_DAEMON
*$ ! ^$XLOOP
* ^Content-Type: text/html
{
        LOG = "$NL --TRASH: HTML $NL"

        # Make a temporary file of the message to be returned
        :0 wc:/tmp/lock

        # Discard whitespaces, insert a leading blank
        | expand | sed -e 's/[ ]*$//g' | sed -e 's/^/ /' > $REJECT

        :0:/tmp/lock
        | ($FORMAIL -r -I "Subject: Rejected Mail: HTML e-mail refusal"\
                -I "From: postmaster(_at_)pcguru(_dot_)com(_dot_)au" \
                -A "X-Mailer: Procmail Autoreply"   \ 
                -A "$XLOOP" ;                       \
                cat $TXT_NO_HTML ;                  \
                echo "--- begin rejected mail ---" ;\
                cat $REJECT ;                       \
                echo "--- end rejected mail ---" ;  \
                rm -f $REJECT                       \
        ) | $SENDMAIL
}
####

## spamassassin
## if the email has gotten to this point, check it against the
## spamassassin to see if it thinks its spam, if it is modify 
## the subject line and what it into the spam folder
:0fw:/tmp/spamlck1
| spamassassin -P

:0e
{
    EXITCODE=$?
}
:0:
* ^Subject:.*\*\*\*\*SPAM\*\*\*\*
caughtspam
##########spamassassin##########


-- 
cheers, jas                       -- http://www.e3.com.au --
e3 - Perth's own Wireless Freenet -- Now with FREE Internet!
Copyright Asserted.  http://www.pcguru.com.au/copyright.html
_______________________________________________
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>