Per user SA-Bayes tokens in SQL

Nick Rosier nick.rosier at
Mon Sep 3 14:30:51 CEST 2012

Thanks Mark,

Mark Martinec wrote:
> Nick,
>> is there a way to configure per-user Bayes tokens for SA?
> Since amavisd-new-2.7.0.
> Note that this implies that for a multi-recipient message
> SpamAssassin will need to be called more than once per message.
>> In my bayes config I've removed the bayes_sql_override_username. Initial
>> training when mail is scanned by Amavis/SpamAssassin still seems to
>> store the tokens as the amavis-user rather than the recipient.
>> Re-training is done with a custom script that configures the user
>> (sa-learn -u). Is it possible to configure Amavis so it passes the
>> recipient to SpamAssassin so it can store per-user Bayes information?
> amavisd-new-2.7.0 release notes:
> - per-recipient (or per- policy bank) SpamAssassin SQL database usernames
>    are supported (setting @sa_username_maps, a policy.sa_username SQL field).
>    This makes it possible to implement per-user or per-user-group or
>    per-domain Bayes databases when SpamAssassin is configured to keep
>    its Bayes database on an SQL server. It also makes it possible to load
>    per-recipient SpamAssassin preferences (configurations) from an SQL
>    database (as described in a previous section).
>    Switching between Bayes usernames is cheap compared to switching between
>    SpamAssassin configuration files.  A multi-recipient message whose
>    recipients map to different usernames will be checked by SpamAssassin
>    multiple times, once for each unique username;
>    Example:
>      @sa_username_maps = (
>        { 'user1 at' =>  'user1',
>          'user2 at' =>  'user2',
>          ''      =>  'user_ex',
>        }
>      );
This is the information I've found so far. It's only not very usefull if 
you would like to consult an SQL-DB. I've got all local users defined in 
my DB so I'd just like to do a 1 on 1 translation:
user1 at => user2 at
user2 at => user2 at
unknown-user at => NULL
someone at => NULL

without having to define them all. Just a simple "select user from 
mailbox" would suffice but I cannot find any documentation on how to do 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the amavis-users mailing list