Complete Virtual Mail Server/White and Black Lists

Introduction
A lot of e-mail addresses used by users should always be considered OK. For example, a users grandmother should always be able to deliver a message to the user. Manually adding all the positive addresses for all the users is not quite easy. Auto white listing using Bayesian filter helps herein. Detailed information about the Bayesian filter can be found on the Spam Assassin website.

Configuration
Spam Assassin needs to be told to start using the Bayesian filter. The configuration file only needs two small changes.

Spam Assasin can and should store the result of its Bayesian filter in an SQL database. The database does not have to be on the same host. If database usage is an issue it is perfectly acceptable to re-use the postfix database. However to keep things nicely separated amavis/spam assassin will get their own database.

Spam Assassin needs to know how to connect to this database and uses the file to store connection information. This file however is installed with only read-permissions by default, so these need to be changed before editing the file. Also amavis will use a local database, but this is by no means required.

This database also needs to be filled. Spam Assassin doesn't distribute these table layouts with the package, but it is available from their svn repository. They should be grabbed and inserted into the database.

Giving amavis access to postgres is the last step required.

Populating the database
The most basic message is the GTUBE test message using the test string from earlier. A test message can be downloaded from the Spam Assassin website and then offered to as spam.

If there is a mailbox available with only ham and a box with only spam, such as and  those could be fed to.

If messages are accidentally identified as spam which should have been ham, or ham which should have been spam the --forget option can be useful.

After this, the Bayesian filter should be updated by Spam Assassin, though manually running the ham and spam commands on various mailboxes won't hurt either.

Testing
Looking at the amavis database it can quickly be verified that the database got properly populated.

Introduction
In addition to the auto Bayesian white list Amavis can also use White/black lists on a per recipient level.

Configuration
For this to work additional tables will need to be created in the postfix database and amavis granted read access.

Then amavis needs to be configured in the Per-recipient and per-sender handling, whitelisting, etc. section how to use the database and how to get data from the database.

Testing
Loading up some sample data into the black/white listing table should be then quite straightforward. This can be then used to send messages.

Sending a message from foo@bar.com should then always be allowed, even the GTube message. Changing the w in b should always block an email address.