# $Id: procmailrc.example 4328 2004-04-13 00:15:29Z relson $
#
# procmailrc.example
#
#	This is a sample procmail setup file that 
#	1 - retains an unprocessed copy of all incoming mail
#	2 - diverts incoming mail with asian character sets
#	3 - runs bogofilter
#	4 - retains a processed copy of all messages identified as spam.
#	5 - retains a processed copy of all messages identified as unsure.
#

### bogofilter - filter & update word lists

MAILDIR=/var/spool/mail
BOGOFILTER_DIR=/var/spool/bogofilter

#### testing ####
## MAILDIR=/tmp/mail
## MAILDIR=/home/user/filter/korean.spam/mail
## procmail procmailrc < input.file ; echo $? ; ll -t $MAILDIR | head
#### end testing ####


#### backup ####
:0c:
mail.backup
####


## Silently drop all completely unreadable mail
:0:
* 1^0 ^\/Subject:.*=\?(.*big5|iso-2022-jp|ISO-2022-KR|euc-kr|gb2312|ks_c_5601-1987|windows-1251|windows-1256)\?
* 1^0 ^\/Content-Type:.*charset="(.*big5|iso-2022-jp|ISO-2022-KR|euc-kr|gb2312|ks_c_5601-1987|windows-1251|windows-1256)
spam-unreadable
####


#### bogofilter passthrough-update ####

:0fw
| bogofilter -p -u -l -e -v
# -p)assthrough -u)pdate, -l)og -e)xitcode 0 for spam and ham
# -v)erbose

#### begin error catcher ####

# m-a 2002-10-28
#     If bogofilter failed, return the mail to the queue.
#     Better put this after _EACH_ delivering recipe (not shown here).
#     Later, the MTA will try again to deliver it.
#     75 is the value for EX_TEMPFAIL in /usr/include/sysexits.h
#
#     Originally published by Philip Guenther on the postfix-users
#     mailing list.

:0e
{
	EXITCODE=75
	HOST
}

#### end error catcher ####


:0c:
* ^X-Bogosity: (Spam|Yes)
spam-bogofilter
# put copy error catcher here to avoid fallthrough

# unnecessary in twostate mode:
:0c:
* ^X-Bogosity: Unsure
unsure-bogofilter
# put another copy of error catcher here to avoid fallthrough

#### end bogofilter passthrough-update ####


#### SpamAssassin ####
# :0c:
# * ^X-Spam-Status: Yes
# spam-spamassassin
#### end SpamAssassin ####
