Train SpamAssassin and apply to all accounts server-wide

SpamAssassin has to be trained before it kicks in. By default SpamAssassin will wait until 200 Spam and 200 Ham messages are "learned." To speed this delay up, reduce the number of messages required to 100 of each by adding the following lines to the /etc/mail/spamassassin/local.cf file:

 bayes_min_ham_num 100
 bayes_min_spam_num 100

Now, chose an email account on the server to act as the model for SpamAssassin training. Using IMAP, create a SPAM and a HAM folder for this account. Copy messages that are spam into the SPAM folder and likewise for HAM. Run the following commands on the command-line, substituting the domain and user names where appropriate:

 sa-learn --spam /var/qmail/mailnames/domain/user/Maildir/.SPAM/*
 sa-learn --ham /var/qmail/mailnames/domain/user/Maildir/.HAM/*

After sufficient training, you'll need to copy the resulting bayes_* files into each email account directory on the server (if you want to use this model's training data server-wide, of course). Consider using the following one-liner to do this:

 find /var/qmail/mailnames -type d -mindepth 2 -maxdepth 2 -exec cp -f   /var/qmail/mailnames/domain/user/.spamassassin/bayes_* {}/.spamassassin/ \; 

The above assumes a .spamassassin directory for each user

Reply

  • You can use Mediawiki syntax. It is possible that not all formatting options are supported at the moment.
    Links to other pages: [[Page Title]] or [[path/to/page|Title]].
    External links: http://example.com or [http://example.com some link title].
    Interwiki links: [[site:Page Title]].
    You can use the following interwiki links: path, gdo, wp

More information about formatting options