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

PHP Startup: Unable to Load Dynamic Library

Server Maintenance | Updated March 2026 "PHP Startup: Unable to load dynamic library" errors...

Repairing and Optimizing all MySQL and MariaDB Databases on the Server

Server Maintenance | Updated 2026 Regularly repairing and optimizing MySQL/MariaDB tables...

Disable cPanel Brute Force Command Line

Server Maintenance | Updated 2026 cPHulk is cPanel's built-in brute force protection. It...

Error: Multilib Version Problems Found

Server Maintenance | Updated March 2026 "Multilib version problems" is a yum error that...

Failed to lock proc mutex: Permission denied

Server Maintenance | Updated 2026 The "failed to lock proc mutex" error in Apache's error log...



Save 30% on web hosting - Use coupon code Hosting30