# $Id: procmail-matej,v 1.4 2005/07/02 21:48:40 matej Exp $ # The main idea of this procmailrc is that it actually saves # mails to different directories just rarely. Mostly, it just # processes spam, fixes some headers, and then (if nothing else # happened -- like for spam) it prints the message back on the # output. # procmail resets all environmental variables, so we set it back. DOMAIN=example HOME=/data/home/$DOMAIN PATH=$HOME/bin:/bin:/usr/bin:/usr/bin # directory where all databases are stored BOGODIR=$HOME/.bogofilter # every email address should be defined only here MYNAME=name # the string which should stand between the name part of email # and actual commands send to bfproxy; it should be special for # given domain, so that spammers cannot register false hams (or # false spams, but who would need it?) COMSTR=secret # mbox folder where all spam is stored (it should not be sent to # /dev/null, because although very rare there may be some false # positives; for inspection use mail -f $SPAMBOX). SPAMBOX=$BOGODIR/junk-$MYNAME #SPAMBOX=/dev/null # all processing of procmail is registered in this file; VERBOSE # can be set to off for less detailed information. LOGFILE=$HOME/log-procmail-$MYNAME VERBOSE=off # ``Chinese'' (and Russian and Hebrew) messages are not # legitimate at all, so bogofilter's databse should not be # stuffed with nonsensical strings from them. UNREADABLE='[^?"]*big5|windows-125[145]|iso-2022-jp|iso-2022-kr|euc-kr|gb2312|ks_c_5601-1987|koi8-r' ######### END OF CONFIGURATION ############ # processing of ``Chinese'' spam -- in headers ... :0: * 1^0 $ ^Subject:.*=\?($UNREADABLE) * 1^0 $ ^Content-Type:.*charset="?($UNREADABLE) /dev/null # ... and in the body of a message :0 * ^Content-Type:.*multipart * B ?? $ ^Content-Type:.*^?.*charset="?($UNREADABLE) /dev/null # There is a spammer, who sends tons of spam under my email # address -- just to keep bogofilter database from him. I really # don't have to do it, but I do. :0 * ^Subject:.*tinnefeld@irb.cs.uni-dortmund.de $SPAMBOX # Is this message a registration message for bfproxy (`f' means # that the pipe content will be further processed and `w' means # that procmail should wait on the completion of pipe)? # One problem with qmail is that it uses dash (instead of more # common plus sign) for subaddressing; bfproxy won't understand # such address, so it has to be cleaned to the standard way of # address+subaddress@domain before stuffing into bfproxy. :0fw * $ ^TO_$MYNAME[-+]$COMSTR-\/[a-zA-Z]+ | formail -I "To: $MYNAME+$COMSTR-$MATCH@$DOMAIN.cz" # If the previous recipe was activated (`A' flag) pass the # message to bfproxy; the result of the filter should be further # processed, because it is now a message with information about # processing (`f' flag again). :0Afw | bfproxy -m $MYNAME -r $COMSTR # In case the previous recipe was not activated (`E' flag), i.e., # this not registration message, run it through bogofilter and # capture changed message (`f' flag) for further processing. :0Efw | bogofilter -uep -d $BOGODIR/$MYNAME # If the message was marked as spam, store it in $SPAMBOX and # that's it (no further processing). :0: * ^X-Bogosity: Spam, $SPAMBOX # And now after all is done, the message should be delivered. # Exclamation mark in the beginning of the action line means that # the message should be forwarded to the given address. Pipe sign # (`|') would mean sending to pipe (see above, but here without # `f' flag, it would mean final delivery to the program). # Otherwise whatever is on the line is understood as a filename # of the mailbox to be delivered to (if it ends with `/' then it # is maildir folder, with `/.' it is MH folder, otherwise mbox). # If the action line (or this whole recipe) is missing, the # message is delivered to /var/spool/$LOGNAME, in our case # /var/spool/$DOMAIN. :0 ! myrealemail@example.net # vi: set ft=procmail nowrap: