How can I manually train Warden with a set of spam or ham messages using the sa-learn command?

Training from a Directory of Messages

Bayes learning will normally not be enabled until at least 200 spam messages have been trained. Normally this is done automatically using the real-time learning, auto learning, or Plesk nightly training script but you may want to speed up the process by starting the training manually. You can use the /usr/bin/sa-learn command to train Warden.

To train a directory of bad messages as spam:

sa-learn -u amavis --no-sync --use-ignores --progress --spam /var/qmail/mailnames/example.com/johndoe/Maildir/.Spam/cur/

To train a directory of good messages as ham:

sa-learn -u amavis --no-sync --use-ignores --progress --ham /var/qmail/mailnames/example.com/johndoe/Maildir/cur

Sync the changes after you are done:

sa-learn -u amavis --sync

To view the current learning statistics from the command line (Statistics can also be viewed from the Warden dashboard under the Anti-spam Learning Statistics widget):

sa-learn --dump magic

Migrating Bayes training data from one server to another

Administrators can also use the sa-learn command to export Bayes data from one server and import it on another. To export the Bayes data run the following command:

sa-learn -u amavis --backup > /tmp/amavis-bayes.db

Transfer the /tmp/amavis-bayes.db file to the other server and run the sa-learn command to import the Bayes data into the Warden database (Warden must be installed first):

sa-learn -u amavis --restore /tmp/amavis-bayes.db

Note: It will likely take at least a few hours to import a large database. It takes about two hours to import a dump with 2 million tokens.

  • sa-learn, training, migrate, import, migration, export, bayes
  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

How can I change the interface language of the extension?

You can change the interface language under Settings -> Application Settings -> Locale...

How can I disable admin email notifications in Amavis?

Amavis has different default options for controlling where virus, spam, banned file attachments,...

How can I whitelist or blacklist a mail server from greylisting?

To Whitelist a Mail Server From Greylisting Navigate to Warden -> Settings ->...

How can I enable third party anti-virus signatures within Warden to improve the ClamAV detection rate?

Warden supports enabling third party anti-virus signatures to improve the detection rate. These...

How can I setup a local caching DNS resolver to speed up DNS queries used by Amavis?

Run the following command to check if local DNS caching is enabled: host -tTXT...