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

Overview

The Warden Bayes filter requires a minimum of 200 trained spam messages before it becomes active. While training typically occurs automatically through real-time learning, auto-learning, or the Plesk nightly script, administrators can initiate manual training to accelerate system initialization.

Manual Training from Message Directories

Use the /usr/bin/sa-learn utility to process existing message directories. Execute the appropriate command based on the intended classification:

    • Train as Spam: Process a directory containing unwanted messages.
sa-learn --spam --username=amavis --use-ignores --local --progress /var/qmail/mailnames/example.com/johndoe/Maildir/.Spam/cur/
    • Train as Ham: Process a directory containing legitimate messages.
sa-learn --ham --username=amavis --use-ignores --local --progress /var/qmail/mailnames/example.com/johndoe/Maildir/cur

Viewing Learning Statistics

Monitor the current state of the Bayes database via the command line or through the Warden dashboard (Anti-spam Learning Statistics widget).

sa-learn --dump magic

Migrating Bayes Data Between Servers

Administrators can export and import Bayes training data to synchronize filters across environments. Ensure Warden is fully installed on the destination server before proceeding.

    1. Export Data: On the source server, generate a backup of the Bayes database.
sa-learn -u amavis --backup > /tmp/amavis-bayes.db
    1. Transfer File: Securely copy the /tmp/amavis-bayes.db file to the destination server.
    2. Import Data: On the destination server, restore the database into Warden.
sa-learn -u amavis --restore /tmp/amavis-bayes.db

Common Issues & Notes

  • Import Duration: Restoring large Bayes databases is resource-intensive. Importing a dump containing approximately 2 million tokens typically requires two hours or more.
  • Activation Threshold: The filter will remain inactive until the required message/token thresholds are met. Use the statistics command above to verify progress before expecting classification changes.
  • sa-learn, training, migrate, import, migration, export, bayes
  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

How can I install or upgrade the extension?

We provide free installation and configuration for all our paid licenses. Open a support ticket...

How can I add stronger Postfix restrictions so that the bulk of spam is rejected at the SMTPD level before it gets processed by Amavis?

Overview Warden enables administrators to enforce stricter Postfix SMTPD restrictions. These...

How can I change the interface language of the extension?

Overview This article provides instructions on how to change the interface language within the...

How can I configure greylisting with Warden Anti-spam and Virus protection?

Overview Greylisting is an email filtering mechanism designed to mitigate spam by temporarily...