Postfix and bogofilter
jim
jim at weathercom.com
Fri Oct 18 10:24:22 CDT 2002
I think postfix/bogofilter is working good enough to tell how I did it. I
don't have procmail installed, so this is how I did it without it. This is
on a mailserver that handles mail for a small number of users.
1. Get postfix installed and running properly.
2. Get bogofilter installed and running properly from the command line.
3. Create a user, I used 'filter' as a username. This user should not be able
to log in, but does need a home directory. I used '/home/filter'.
4. Put the bogofilter executable in /usr/sbin
5. Put the following script in /usr/sbin
#!/bin/bash
export PATH=$PATH:/usr/sbin
export HOME=/home/filter
cd $HOME
bogofilter -p | sendmail -i "$@"
6. In the master.cf configuration file for postfix, find the line that looks
like:
smtp inet (some other stuff) smtpd
and add this line after it.
-o content_filter=filter:
Be sure to include the ':' at the end of the line.
7. Append these lines to the end of the master.cf file:
filter unix - n n - - pipe
user=filter argv=/usr/sbin/filtermail -f ${sender} -- ${recipient}
8. Do a 'postfix reload'.
9. Now, anything bogofilter recognizes as spam will have a header that looks
like:
X-Spam-Status: Yes, tests=bogofilter
and anything it doesn't think is spam will look like:
X-Spam-Status: No, tests=bogofilter
10. Even though bogofilter is now filtering your email. It doesn't know what
to look for to distinguish spam from real email. Create two other mail
accounts, one for spam and one for non-spam. Anytime you receive spam that
bogofilter doesn't catch, forward it to the spam address. Anytime you
receive good mail that bogofilter thinks is spam, forward it to the non-spam
address. Periodically, log on to the mail server and go to the directory
where the spam mails are. 'su' as the user 'filter' and do a 'cat * |
bogofilter -s'. Delete all the spam files. Then go to the directory where
the good emails are and do a 'cat * | bogofilter -h'. Then delete all the
good emails. Hopefully, the performance of bogofilter improves over time.
Bogofilter has a bug where the last line is sometimes duplicated using the
'-p' option.
More information about the Kclug
mailing list