How To Set Up Spam Filter Rules in cPanel
Spam filter rules help manage incoming email by identifying messages that match specific conditions and applying actions based on those rules. These filters can be configured to block unwanted senders, allow trusted contacts, or handle emails based on their content and other criteria.
This article explains how spam filter rules work and provides instructions on how to configure them in cPanel using available filtering options such as auto-delete, blacklist and whitelist settings, and user-defined filters.
What is a Spam Filter?
A Spam Filter (powered by Apache SpamAssassin™) helps keep your inbox clean by scanning incoming emails for spam or unwanted messages.
When spam is detected, it can either be automatically deleted or moved to a separate spam folder. You can review and manage this folder anytime, or set it to empty automatically.
What Are Blacklist and Whitelist Filters?
- A blacklist filter allows you to block specific email addresses, preventing their messages from reaching your inbox.
- A whitelist filter allows you to specify trusted email addresses that should always bypass spam filtering.
What is a Bayes Filter?
A Bayes (or Bayesian) filter is a spam detection method that analyzes the entire content of an email—not just the subject line or headers—to determine whether it is spam.
It works by comparing the email’s content against patterns and rules learned over time, helping identify messages that are likely unwanted.
This method is based on Bayes’ Theorem, a statistical principle developed by mathematician Thomas Bayes.
Set Up Spam Filter Rules in cPanel
There are several ways to configure spam filters in cPanel:
Spam Filter (powered by Apache SpamAssassin™) has an auto-delete option. To enable the auto-delete feature, follow the steps below:
- Access your cPanel.
- Go to the Email and click Spam Filters.
- On the Spam Filters page, make sure Process New Emails and Mark them as Spam is turned on first.
- Toggle on the Automatically Delete New Spam (Auto-Delete) feature.
- Click Configure Auto-Delete Settings.
- In the Auto-Delete Threshold Score text box, enter your desired score.
- Click Update Auto-Delete Score to confirm.
- It is highly recommended that the Score be set higher than 5, so legitimate messages are not accidentally flagged as Spam.
- To disable the Auto-Delete, toggle the Automatically Delete New Spam (Auto-Delete) feature off.
You can configure blacklist and whitelist filters directly to control which emails are blocked or allowed.
Follow the steps below:
- Access your cPanel.
- Go to the Email section and click Spam Filters.
- Scroll down to Additional Configurations (For Advanced Users).
- Click either:
- Edit Spam Whitelist Settings (to allow specific email addresses), or
- Edit Spam Blacklist Settings (to block specific email addresses).
- On the next page,
- Enter the email addresses you want to block in the blacklist_from field.
- Enter the email addresses you want to allow in the whitelist_from field.
- Click:
- Update Blacklist (blacklist_from),or
- Update Whitelist (whitelist_from) to save your changes.
To further enhance your Email Hosting spam filtering process, you can also create specific email filters in User Filters that will dictate your email system how to handle spam messages. This is basically the Bayes filter for your email account.
If you want to know how to create email filters, click here.
To help you further understand filter rules and criteria when creating email filters, refer to the table below:
-
Parts of the Email To Be Examined
-
These are your options on which part of the email message you want the spam filter to examine and compare with the values or criteria you set in the field below the operators.
From This is the sender's address. Subject This is the message's subject line. To This is the recipient's email address.
NOTE: Generally, the recipient does not receive the BCC field in an email's header. For this reason, you cannot use the BCC field in a filter.
Reply Address This is the address at which the sender receives replies. Body This is the main content or body of the email. Any Header This refers to any part of the message's header. Any Recipient This refers to any recipient of the message. Has not been previously delivered This means that the system only examines messages that remain in the queue for delivery. is an Error Message This means the system only examines error messages that an auto-response system sends. List ID This refers to the account's mailing lists. Spam Status This is whether Apache SpamAssassin marked the message as spam or not. The Spam Status line begins with Yes or No. Spam Bar This is the content of the Spam Bar header that Apache SpamAssassin generated for this message. The more plus signs (+) that Apache SpamAssassin assigns to a message, the greater the likelihood that the system marks the message as spam. Spam Score This is the total number of plus signs (+) in the Spam Bar value, expressed as an integer.
Operators -
These options will determine what type of comparison you want the Spam filter to perform.
equals The message exactly matches a defined string. matches regex The message matches a regular expression that you define.
NOTE: The filter text box accepts regular expressions when you select this option, rather than more commonly-used wildcard characters (for example, * or ?).
contains The message, a string that you define. does not contain The message does not contain the defined string. begins with The message begins with the defined string. ends with The message ends with the defined string. does not begin The message does not begin with the defined string. does not end with The message does not end with the defined string. does not match The message does not exactly match the defined string.
Criteria -
This is the field where you type in the characters, text, or other variables that the spam filter will look out for in the incoming email messages, according to the specifications you set in the two text boxes above.
-
Actions -
This is where you specify the outcome or consequence that will be applied to the conditions you have set in Rules.
Discard Message The system discards the incoming message with no failure notice. Redirect to email The system forwards the message to another email address that you specify. Fail with message The system discards the message and automatically sends a failure notice to the sender. Stop Processing Rules The system skips all filter rules. Deliver to folder The system delivers the message to a specified folder. Pipe to a program The system sends the incoming message to a specified program. For more information, read the Pipe to a Program section below.
Congratulations! You’ve successfully set up your spam filter rules in cPanel and can enjoy a cleaner, more manageable inbox.