Prevent Spam Emails by Training cPanel’s Spam Filters Bayes with HAM and SPAM


cPanel’s Spam Filters identifies unwanted and suspicious emails by analyzing message content, headers, sender information, authentication, predefined rules, reputation checks, and Bayesian filtering. Each email is assigned a spam score that determines how it is handled. Based on configured score thresholds, emails can be marked as spam, moved to Junk, or automatically discarded. Bayesian filtering can be trained with legitimate (HAM) and unwanted (SPAM) emails, helping spam receive higher scores while reducing false positives for legitimate emails. This allows high-scoring spam to be more effectively filtered or discarded automatically.

Understanding Spam Score
A common cPanel Spam Filters configuration uses a score of 5.0 or higher to identify an email as spam. You can enable “Move New Spam to a Separate Folder (Spam Box)” to move such messages to the Spam/Junk folder, while “Automatically Delete New Spam (Auto-Delete)” can be configured with a higher score, such as 10 or 12, to automatically discard high-scoring spam. However, some unwanted emails may receive only a 2.0 or 3.0 score and still reach the Inbox. Simply lowering the spam threshold can increase false positives and cause legitimate emails to be treated as spam, which is where Bayesian training can help improve scoring accuracy.

What Is Bayesian Filtering (Bayes)?
Bayesian filtering, commonly referred to as Bayes, learns from emails classified as legitimate (HAM) or unwanted (SPAM). Instead of relying only on predefined filtering rules, Bayes learns patterns, words, and other characteristics associated with each type of email. When a new message arrives, Bayes compares it with what it has previously learned and contributes to the message’s overall spam score. Depending on how strongly the message resembles learned SPAM or HAM, Bayes can increase or decrease its spam score rather than assigning a fixed score to every trained message.

What Are HAM and SPAM?
HAM refers to legitimate emails that you actually want to receive, such as genuine customer inquiries, supplier correspondence, quotations, invoices, order confirmations and normal business communication. SPAM refers to unwanted emails such as unsolicited advertisements, Spoofing, fake offers, scams and repetitive junk messages. HAM training therefore teaches Bayes what your legitimate email looks like, while SPAM training teaches it what your unwanted email looks like. Both types are important because training only SPAM does not give Bayes enough information to properly understand the difference between genuine and unwanted messages.

How Much HAM and SPAM Training Is Required?
In a standard Spam Filters configuration, Bayes normally requires at least 200 HAM and 200 SPAM messages before Bayesian classification starts being used. Reaching 200 messages in each category should also be considered a starting point rather than the end of training.

Recommended Bayes Training Process
There are different ways to train the Bayes filtering system, but we recommend the following two methods because they are simple and practical. The first method is initial bulk training with the help of server administrator (datacenter), where you prepare a larger collection of confirmed HAM and SPAM emails and the datacenter performs the initial Bayes training. The second method allows you to train Bayes yourself on an ongoing basis by correctly identifying legitimate and unwanted emails as they arrive. Both methods are explained below.

Method 1: Initial Bulk Bayes Training with the Help of Datacenter
For the first method, log in to your Webmail and create a separate folder named HAM. Carefully move approximately 200 confirmed legitimate emails into this folder. For SPAM, use the existing Junk/Spam folder and make sure it contains approximately 200 confirmed unwanted emails. Do not simply treat the entire Inbox as HAM or the entire Junk/Spam folder as SPAM without reviewing the messages, because either folder may contain incorrectly classified emails. Once both sets are ready, contact us so we can ask the datacenter to run the Bayes training script using your confirmed HAM and SPAM emails. This provides Bayes with an initial collection of known legitimate and unwanted emails from which it can learn.

Method 2: Ongoing Bayes Training You Can Perform Yourself
The second method allows you to continue training Bayes yourself as new emails arrive. This training should be performed directly through your Webmail. If an unwanted email arrives in your Inbox, select it and click Junk/Spam so that it can be learned as SPAM. If a legitimate email is already in your Inbox and you want Bayes to learn it as HAM, manually move that email to the Junk/Spam folder. Then open the Junk/Spam folder, select the email, and click Not Junk/Not Spam so that it can be learned as HAM. Continue correctly identifying new legitimate and unwanted emails in this way whenever necessary. Over time, Bayes learns from more HAM and SPAM examples, helping it make more accurate filtering decisions for similar emails in the future.

Can Bayes Completely Stop Spam Emails?
No spam filtering system can guarantee a 100% spam-free Inbox, but proper and continued Bayes training can significantly improve how accurately unwanted and legitimate emails are identified. Since spam patterns continue to change, Bayes training should not be treated as a one-time process. Continue correctly classifying HAM and SPAM so Bayes can adapt to the type of email your mailbox receives and improve filtering over time.

If you need further assistance with Spam Filters, Bayes training, or email spam configuration, you may contact our support team on WhatsApp at 0313-4710222.