SpamAssassin Command Line Bayesian Learn Command cPanel

Server Maintenance | Updated 2026

SpamAssassin's Bayesian filter learns from your email to improve spam detection accuracy. Training it with known spam and known ham (legitimate email) significantly improves filtering over time.

Server Admin Only

Bayesian training requires server access

Shared hosting customers can train SpamAssassin by moving spam to the Junk/Spam folder in webmail. The server periodically learns from these folders. For manual training at the server level, root SSH is required.

01. Manual Training (Root Access)

# Learn spam from a mailbox's spam folder
sa-learn --spam /home/username/mail/domain.com/user/Maildir/.Junk/cur/

# Learn ham (not spam) from inbox
sa-learn --ham /home/username/mail/domain.com/user/Maildir/cur/

# Check database statistics
sa-learn --dump magic

02. Automatic Learning

SpamAssassin auto-learns when configured with bayes_auto_learn 1 in /etc/mail/spamassassin/local.cf. Messages scoring very high (above bayes_auto_learn_threshold_spam, default 12.0) are automatically learned as spam. Messages scoring very low (below bayes_auto_learn_threshold_nonspam, default 0.1) are learned as ham.

Shared Hosting Users

To improve spam filtering on your account: move spam to your Junk/Spam folder (do not just delete it), mark legitimate emails as "Not Spam" if they land in Junk, and adjust your SpamAssassin score threshold in cPanel > Email > Spam Filters. See Greatly Reduce Spam.

Spam Getting Through?

Open a Support Ticket

Quick Recap

  1. sa-learn --spam and --ham for manual training
  2. Auto-learn with bayes_auto_learn in local.cf
  3. Shared hosting: Move spam to Junk folder to train
  4. 200+ messages of each type needed for Bayesian to activate
  5. Check with sa-learn --dump magic

Server administration · Last updated March 2026 · Browse all Server Maintenance articles

  • 165 Users Found This Useful

Was this answer helpful?

Related Articles

Remount /tmp with exec permission

Server Maintenance | Updated 2026 Some software installations and compilation tasks require...

Error: rpmdb Open Failed with cPanel

Server Maintenance | Updated March 2026 The "rpmdb open failed" error means the RPM database...

ModSecurity: collection_store: Failed to access DBM file /var/cpanel/secdatadir/ip: Permission denied

Server Maintenance | Updated 2026 The error collection_store: Failed to access DBM file...

Create CXS Quarantine Directory

Server Maintenance | Updated 2026 ConfigServer eXploit Scanner (CXS) quarantines suspicious...

error: db3 error(-) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery

Server Maintenance | Updated 2026 The error db3 error(-30974) from dbenv->failchk:...



Save 30% on web hosting - Use coupon code Hosting30