[[procmail]]
 

My latest procmailrc

# gavin@metahusky.net:.procmailrc
# 19/04/05 - Overhauled the recipes. Updated comments, as some stuff has
# been uncommented for four years.
# 30/05/07 - Added greylisting. Based loosely on pete@ebi.ac.uk's 
# procmail greylisting. 
 
PATH=/bin:/usr/bin:/usr/local/bin
VERBOSE=on
MAILDIR=$HOME/Mail
LOGFILE=/usr/home/gavin/Mail/procmail.log
TO=`/usr/local/bin/formail -x To:`
CC=`/usr/local/bin/formail -x Cc:`
FROM=`/usr/local/bin/formail -x From:`
SUBJECT=`/usr/local/bin/formail -x Subject:`
 
## Start the filtering.
 
# Straight out of `man procmailex` - recreate the From header.
 
:0 fhw
| formail -I "From " -a "From "
 
# Ditch the spam that says "Hi! I'm spam" straight away.
# This does actually catch some spam. If only the rest of the spammers put
# SPAM at the start of their subject lines...
 
:0:
* ^Subject:.*SEXUALLY
/dev/null
 
# All the auto-replies I send out have an X-Loop header. Catch these.
:0:
* ^X-Loop:.gavin@metahusky.net
/dev/null
 
:0:
* To:.*nutters
`date +%b%Y`
 
# Drop email from blacklisted addresses.
:0:
* ? echo $FROM | grep -i -f senders.deny
blacklisted
 
# Deliver emails to me from allow senders.
:0:
* ? echo $FROM | grep -i -f senders.allow
`date +%b%Y`
 
# Catch emails from people who are adding themselves to my whitelist.
:0c
* ^Subject:.*74han35
`date +%b%Y`
 
# Mail from real people get added to the whitelist.
:0 w:fromlock
* ^Subject:.*74han35
{
   # extract sender's address proper (w/o < >)
   :0 h
   EADDR=| /usr/local/bin/formail -x"From " | sed 's/^\([^@]*[ <]\)//' | sed 's/\([ >]\).*$//'
 
   # append sender's address to white list.
   :0 ch
   *
   | echo $EADDR >> senders.allow
 
   :0
   | (/usr/local/bin/formail -r;\
     echo Thank you. You have been added to the whitelist. Email to gavin@metahusky.net;\
     echo will be accepted as normal.;\
     echo Your last message has been delivered. Please continue as normal.)\
     | $SENDMAIL -t -oi
 
}
 
# SpamAssassin
:0fw
* < 256000
| /usr/local/bin/spamassassin
 
:0:
* ^X-Spam-Status: Yes
spam
 
:0:
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
spam
 
 
# If the user isn't on the whitelist and the mail isn't tagged as spam, then
# who are they?! Reply so legitimate people who haven't emailed me before
# can get through. False negatives also get replied too, naturally, but I
# don't see their emails, which is fine. Real people will jump through the
# whitelist hoops.
 
:0c
greylist
 
:0 h
| ( /usr/local/bin/formail -r -I"From: gavin-noreply@metahusky.net" -A"X-Loop: gavin@metahusky.net";\
	cat bounce.txt ) |  $SENDMAIL -t -oi -fgavin-noreply@metahusky.net
 
 

My good old .procmailrc

PATH=/bin:/usr/bin
#VERBOSE=on
MAILDIR=$HOME/Mail
LOGFILE=/usr/home/gavin/Mail/procmail.log
CYRUSDELIVER=/usr/local/bin/cyrus-deliver-wrapper
TO=`/usr/local/bin/formail -x To:`
CC=`/usr/local/bin/formail -x Cc:`
FROM=`/usr/local/bin/formail -x From:`
SUBJECT=`/usr/local/bin/formail -x Subject:`
DATE=`date`
#BLEH=`echo $DATE 'From:' $FROM 'To:' $TO 'Cc:' $CC 'Subject:' $SUBJECT >> /usr/home/gavin/Mail/mail.log`
#BLEH2=`echo $TO >> /usr/home/gavin/Mail/toaddress.log`
 
# dspam spam filtering:
:0fw
| /usr/local/dspam/bin/dspam --stdout --deliver-spam
 
:0: 
* ^X-DSPAM-Result: spam
dspam
 
# End spam treatment.
 
# SpamAssassin
:0fw
* < 256000
| /usr/local/bin/spamassassin
 
:0:
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
spam
 
:0:
* ^X-Spam-Status: Yes
spam
 
# - END SPAMASSASSIN STUFF
 
# NOTES:
# . Stuff that comes to me 'magically' by Bcc's will drop to 'junk'.
# . Stuff that comes to me via aliases I'm not aware of will drop to 'junk'.
# . A note of every To address that I get is noted in ~/logs/toaddress.log
 
# Drop duplicates from crossposts.
#:0 Wh: msgid.lock
#| /usr/local/bin/formail -D 8192 msgid.cache
 
# Get the obvious stuff out of the way.
 
# This does actually catch some spam. If only the rest of the spammers put
# SPAM at the start of their subject lines...
 
:0:
* ^Subject:.*SEXUALLY
spam
 
# Mailing lists
 
:0:
* ^TOtoasters
toasters/`date +%b%Y`
 
:0:
* ^TOtru64-unix-managers
tru64/`date +%b%Y`
 
:0:
* ^TOsunmanagers
sun/`date +%b%Y`
 
:0:
* ^TOnetworker
networker/`date +%b%Y`
 
# Copy stuff to the colo to the colo folder.
:0c
* ^TOcolo
colo/`date +%b%Y`
 
 
#:0:
#* ^TO
#ebay/`date +%b%Y`
 
# New mailfile backup each month.
:0 c
backups/`date +%b%Y`
 
# Drop html only mail.
# Bah no don't cos ppl here keep sending it in both formats. Fools.
# Disabled 15/10/2001.
 
#:0:
#* ^Content-Type: text/html|multipart/alternative
#junk
 
# mail addressed to me (as specified in the file) plonk into my normal
# mailbox. Stuff sepcifically addressed to me but which I class as
# junk, goes to junk. Anything else goes to junk. This is mainly for
# damn legitimate places that refuse to take me off their mailling lists,
# ie monster.co.uk.
 
# Note: Should really make this so I can have a list of regexps on a new
# line in the junksenders file and built a nice collection of antispam 
# regexps. But I've had no need to yet.
 
# June 2003 - Add more domains to senders.deny - those which get through
# spamassassin.
 
:0:
* ? echo $FROM | grep -i -f /usr/home/gavin/Mail/senders.deny
spam
 
#:0 fhw
#| /usr/local/bin/formail -I "From "
 
# Changed 12/11/2001. Cyrus needs the message without the From header. No
# idea why, but if you lose the From header, the mailspool is no longer in
# mbox format, so the header is trimmed ONLY for cyrus delivers.
 
#:0
#* ? echo $TO | grep -i -f /usr/home/gavin/Mail/myaddress
#| /usr/local/bin/formail -I "From " | $CYRUSDELIVER user.gavin
 
#:0
#* ? echo $CC | grep -i -f /usr/home/gavin/Mail/myaddress
#| /usr/local/bin/formail -I "From " | $CYRUSDELIVER user.gavin
 
 
# Write legitimate mail to a folder with the name of current month and year.
# This stops my inbox from getting to big. Mutt is set to read the mailbox
# name in the same fashion, so it's all transparent.
 
:0:
* ? echo $TO | grep -i -f /usr/home/gavin/Mail/to.allow
`date +%b%Y`
 
#:0:
#* ? echo $TO | grep -i -f /usr/home/gavin/Mail/to.allow
#/var/mail/gavin
 
:0:
* ? echo $CC | grep -i -f /usr/home/gavin/Mail/to.allow
`date +%b%Y`
 
#:0:
#* ? echo $CC | grep -i -f /usr/home/gavin/Mail/to.allow
#/var/mail/gavin
 
:0:
* ? echo $FROM | grep -i -f /usr/home/gavin/Mail/senders.allow
`date +%b%Y`
 
#:0:
#* ? echo $FROM | grep -i -f /usr/home/gavin/Mail/senders.allow
#/var/mail/gavin
 
# Not been filtered? Drop it to the junk folder. Never throw anything to
# /dev/null, review the junk folder occasionally for mail that has been
# junk'ed for the wrong reason.
 
:0:
*
spam
 
 
procmail.txt · Last modified: 2007/09/27 15:37 by gavin
 
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki