At 03:43 PM 10/3/2003 -0700, you wrote:
At 02:50 PM 10/3/2003, Doug Ledbetter wrote:
Hello all,

        I've setup SpamAssassin to work with individual Vpopmail mailboxes.  I want to know if sa-learn can be used in this configuration?  If so, how do you tell sa-learn which Bayes database you want to use?  I'm currently using one Bayes database per email domain, but I may offer individual Bayes databases per mailbox in the future.


I would be interested in how you set SA up with individual vPop boxes. Do you have any notes to share??

Sure, let me ramble for a minute.  ;)

First, I should mention that I wanted maximum control over how SpamAssassin works for individual mailboxes.  I wanted to be able to turn it on/off individually and configure SpamAssassin settings (ie- Razor, hits, Bayes DB location, etc.) individually for each mailbox and I wanted to store all this in an SQL database for ease of use.

- Obviously you need SpamAssassin installed.  :)

I had to make a small change to one of the SpamAssassin scripts because normally it won't read certain settings from a database for security reasons.  Notice I have modified the source of SpamAssassin!  Please use at your own risk!  As long as access to your database is secure, you shouldn't have any problems.


Around line 280:

sub parse_scores_only {
  my ($self) = @_;
#  $self->_parse ($_[1], 1); # don't copy $rules!
  $self->_parse ($_[1], $disallow_rules_in_sql); # allow copying of rules -dougl


my $disallow_rules_in_sql = 0;

- Here's how I run the "spamd" daemon:

        spamd -d -a -v -x -q -u vpopmail -H /home/vpopmail/

- OPTIONAL:  Install Razor.  Run 'razor-admin -create' & ' razor-admin -register' as the vpopmail user.  This creates a .razor directory in /home/vpopmail.  Don't forget to patch Razor if you're using SpamAssassin 2.60 (patch is included with SpamAssasin v2.60).

- Make sure you have a recent version of Procmail installed.

- Create a .procmailrc file and put it in the mailbox directory (ie- /home/vpopmail/domains/<domain>/<user>/.procmailrc

        Contents of .procmailrc:
# Note:  paths in this file are relative to the email domain directory.
# ie- /home/vpopmail/domains/<domain>/
# The following 4 lines do verbose procmail logging useful for debugging.
# Comment them out before receiving a lot of email.  ;)
SPAMBOX="./spam/Maildir/"       # optional
USER="<full email address of mailbox>"
# SpamAssassin filter
| /usr/bin/spamc -d -u ${USER} -t 3
# If you want procmail to put spam messages into another mailbox,
# uncomment these next lines and be sure that "SPAMBOX" is a valid
# mailbox
# Toss Spam into another maildir
#* ^X-Spam-Flag:.YES
# Deliver the mail to the Maildir

        NOTE:  The above .procmailrc has Procmail doing the mail delivery and NOT vdelivermail which means you won't get email quota support.  If you want to use vdelivermail, it's a little bit more tricky.

- Edit the .qmail-<user> file for the mailbox you want to set up SpamAssassin:

| preline /usr/bin/procmail -t  ./<user>/.procmailrc

- Known problem:  SpamAssassin will not process email sent to a catch-all account.  Ie- you have a .qmail-default in the vpopmail domain directory that says something like this:

| /home/vpopmail/bin/vdelivermail '' <some email address>

The next version of Vpopmail should fix this problem.

- Create a MySQL database according to the SpamAssassin docs.  Then you can insert records like this:

mysql> select * from userpref;
| oid | username                 | preference          | value                                                                  | updated        |
|   1 | <full email address> | use_bayes           | 1                                                                      | 20030924164532 |
|   6 | <full email address> | bayes_path          | /home/vpopmail/domains/<domain>/.spamassassin/bayes          | 20030924164532 |
|   4 | <full email address> | report_safe         | 0                                                                      | 20030924164532 |
|   7 | <full email address> | auto_whitelist_path | /home/vpopmail/domains/<domain>/.spamassassin/auto-whitelist | 20030924164532 |
|   9 | <full email address> | auto_learn          | 1                                                                      | 20030924164532 |
|  10 | <full email address> | rewrite_subject     | 1                                                                      | 20030924164532 |
|  11 | <full email address> | required_hits       | 5.0                                                                    | 20030924164532 |
|  12 | <full email address> | use_razor2          | 0                                                                      | 20030924164532 |
8 rows in set (0.02 sec)

Each user (ie- full email address) can have it's own settings in this table.  This makes it really easy to turn on/off every SpamAssassin option on an individual basis.

Note:  Currently I'm using one Bayes database per email domain, but I could change that to use one database per mailbox or one database for the entire system right in the SQL table.

These above settings will mark email with the "X-Spam-Flag:" header and you can configure the email client to filter messages unless you un-comment the lines in the .procmailrc file to direct spam messages to a different mailbox.

I think that's most of it.  I know this description was unorganized and sketchy, please feel free to ask questions.



Doug Ledbetter -- Hagen Software, Inc.
My PGP Public Key:

Reply via email to