Plugin that checks if the mail is spam by using the ``spamd'' daemon from the SpamAssassin package. Unlike the spamassassin plugin in the core distribution, this plugin allows per-recipient configuration.

SpamAssassin 2.6 or newer is required.


Configured in the plugins file without any parameters, the spamassassin plugin will add relevant headers from the spamd (X-Spam-Status etc).

The format goes like

  spamassassin  option value  [option value]

Options being those listed below and the values being parameters to the options. Confused yet? :-)

reject_threshold [threshold]

Set the threshold over which the plugin will reject the mail. Some mail servers are so useless that they ignore 55x responses not coming after RCPT TO, so they might just keep retrying and retrying and retrying until the mail expires from their queue.

I like to configure this with 15 or 20 as the threshold.

The default is to never reject mail based on the SpamAssassin score.

munge_subject_threshold [threshold]

Set the threshold over which we will prefix the subject with '*****SPAM*****'. A messed up subject is easier to filter on than the other headers for many people with not so clever mail clients.

The default is to never munge the subject based on the SpamAssassin score.

spamd_socket [/path/to/socket]

Beginning with Mail::SpamAssassin 2.60, it is possible to use Unix domain sockets for spamd. This is faster and more secure than using a TCP connection.

leave_old_headers [drop|rename|keep]

Another mail server before might have checked this mail already and may have added X-Spam-Status, X-Spam-Flag and X-Spam-Check-By lines. Normally you can not trust such headers and should either rename them to X-Old-... (default, parameter 'rename') or have them removed (parameter 'drop'). If you know what you are doing, you can also leave them intact (parameter 'keep').

With both of the first options the configuration line will look like the following

 spamasssasin  reject_threshold 18  munge_subject_threshold 8

Per-Recipient Configuration

The following address notes are recognized by this plugin

spamassassin_reject_threshold [threshold]

Overrides the reject_threshold for this recipient. If there are several recipients and the mail should be rejected for some and accepted for the others a temporary failure is generated and the cf_wrapper plugin is used to weed out the recipients at the next delivery attempt. Ths may cause some mail to be delayed.

spamassassin_munge_subject_threshold [threshold]

Overrides the munge_subject_threshold for this recipient. If there are several recipients with different munge_subject_thresholds, the lowest one will be used. It is not possible to pass on a mail to several recipients with different munging. Either the subject is munged for all of them or none.

spamassassin_user [username]

The user to run as. This username will be passed to spamd and spamd will read the configuration files in the user's home directory. This allows the user e.g., so set different scores for some rules and to use their bayesian filter database. It does not allow the use of custom rules. See the spamd documentation for details.


This plugin depends on several other plugins:


The cf_wrapper plugin implements a framework for filters which hook into data_post to reject messages for only some recipients (which SMTP isn't designed for).


The address_notes plugin extends the class Qpsmtpd::Address with a method notes, which works similarly to connection and transaction notes. This allows passing around notes on recipients.


Finally you need a plugin to set those address notes which spamassassin_rcpt queries. At the time of this writing the only one to do this is address_notes_aliases, which in turn needs the aliases_check plugin to parse a config file. Feel free to write one which gets the data from LDAP or an SQL database instead!

In the plugins configuration file, the spamassassin_rcpt plugin needs to be after the address_notes_aliases (or equivalent) plugin but before the cf_wrapper plugin.


Make the ``subject munge string'' configurable

Implement autolearning.


Copyright (c) 2006 Peter J. Holzer <>.

This plugin is licensed under the same terms as the qpsmtpd package itself. Please see the LICENSE file included with qpsmtpd for details.