Training SpamAssassin to Work with All Mail Accounts on the Server

You can manually train SpamAssassin to work with all mail accounts on the server from the command line.

To train SpamAssassin to work with all mail names on the server:

  1. Store spam and ham (non-spam) messages in two different folders, for example spam_mails and ham_mails.
  2. Train SpamAssassin to work with one mailbox using the messages from these folders:

    # cd /path/to/spam_mail/

    # for message in * ; do /usr/local/psa/admin/sbin/spammng --bayes --spam=$message ; done

    # cd /path/to/ham_mail/

    # for message in * ; do /usr/local/psa/admin/sbin/spammng --bayes --ham=$message ; done

  3. Repeat this command for every mailbox on the server or just copy bayes bases (./*) from this mailbox to other mailboxes with the following command:

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

    where and mailname should be replaced with the real domain name and mail name.


Leave your comments on this page

Leave your feedback or question on this documentation topic below. For technical assistance, contact your hosting service provider or submit a request to Plesk support. Suggest new features for Plesk here. Discuss general questions on the Plesk forum. All offtopic comments will be removed.