HOWTO: Courier with Virtual Domains and SpamAssassin

Document version: 0.1; created 2004-02-04.

Patching spamd


This document describes how to patch SpamAssassin to work with Courier virtual domains. The problem is that SA does not recognize the homedirs of the virtual users and therefore, sadly, does not read the bayes database and user_prefs files for virtual users. The patch used here overrides the homedir retrieving function in SA. If you followed the documentation linked below, you may have noticed that sa-learn puts the bayes db into the right place, but spamc/spamd look in the wrong place. Hence, we will patch spamd with the AuthCourier patch by Alan Milligan. This document does not cover patching spamassassin, so you either are stuck to use spamc/spamd (which is in most cases the better approach anyway) or you have to patch spamassassin yourself (in which case I would be interested in your story to include it here ;-).


You should have the basic setup of Courier and SpamAssassin done. Maybe the following documents are helpful: Virtual Mail Hosting with the Courier Mail Suite and Bayesian filtering with SpamAssassin, courier-imap and maildrop.

Make sure authdaemon is active as authentication service or courier. The patch relies on that.

andaka:/etc/courier# grep -re '^AUTHMODULES' *

Every AUTHMODULES line in these files should contain the authdaemon, which should be configured to use the correct authentication module.

Patching spamd

Go to the perl library directory, and there into Mail/Spamassassin. On a Debian system, it is in /usr/share/perl5/Mail/SpamAssassin/. Save the (many thanks to Alan Milligan for the patch) there:

andaka:~# cd /usr/share/perl5/Mail/SpamAssassin/
andaka:/usr/share/perl5/Mail/SpamAssassin# wget

Now you need to put one tiny little line into spamd, maybe found in /usr/sbin/ or /usr/local/sbin. Keep looking for a block of use-statements that import a bunch of SpamAssassin modules. They should look like this (lines 33-35 in SpamAssassin version 2.61):

use Mail::SpamAssassin;
use Mail::SpamAssassin::NoMailAudit;
use Mail::SpamAssassin::NetSet;

Immediately after that block, insert one line:

use Mail::SpamAssassin::AuthCourier;

You're set, now restart spamd by running e.g. /etc/init.d/spamassassin restart.

Copyright 2004 by Dave Kliczbor. Feedback in english or german welcome. Original location of this document:
Free distribution of this document is allowed.
The file referenced in this document is written by Alan Milligan (alan at balclutha dot org) and copyrighted 2003-04 by Corporation of Balclutha.