In short
cPanel has two kinds of filters: Email Filters, which apply to a single account, and Global Email Filters, which apply to all mail for the cPanel account. They let you block a sender or a domain, move messages by spam score and set suspicious mail aside. They don't replace an antispam: they check one message at a time with fixed rules. For the whole server there is also the Exim system filter, configured in WHM.
Which filters cPanel has
| Tool | Where | Scope | What it's for |
|---|---|---|---|
| Email Filters | cPanel › Email › Email Filters | One email account | Personal rules: move, forward or discard |
| Global Email Filters | cPanel › Email › Global Email Filters | Every account in that cPanel account | Blocking a sender for the whole company |
| Spam Filters lists | cPanel › Email › Spam Filters | Every account in that cPanel account | Adding or removing SpamAssassin points for a sender |
| Exim system filter | WHM › Exim Configuration Manager › Filters | The whole server | Administrator rules that affect every customer |
If you want to tune the SpamAssassin score or the spam folder, that is covered in how to configure SpamAssassin in cPanel. This guide covers condition-based rules.
How to create a filter step by step
- Go to cPanel › Email › Global Email Filters (or Email Filters, and pick the account).
- Click Create a New Filter and give it a name that explains why it exists, for example "Block fake invoices".
- Under Rules, choose the part of the message (From, Subject, To, Any Header, Body, Spam Status, Spam Score…), the operator (contains, matches regex, begins with…) and the value.
- Under Actions, choose what to do: Deliver to Folder, Redirect to Email, Fail with Message, Discard Message or Stop Processing Rules.
- Save and test it with the Filter Test tool on the same page, pasting the headers of a real message.
Seven useful rules against spam and phishing
| Goal | Rule | Action |
|---|---|---|
| Block a sender | From · contains · offers@spam-domain.com | Deliver to Folder "Review", or Discard |
| Block a whole domain | From · ends with · @spam-domain.com> | Discard Message |
| Keep near-certain spam out of the inbox | Spam Score · is greater than · 10 | Discard, or Deliver to Folder "spam" |
| Mail from heavily abused domain extensions | From · matches regex · \.(top|xyz|click|shop)>?$ | Deliver to Folder "Review" |
| Impersonation of your manager's name | From · contains · First Last, and From · does not contain · @yourcompany.com | Deliver to Folder "Review" |
| Fake "mailbox full" notices | Subject · matches regex · (mailbox|quota).*(full|exceeded|suspend) | Deliver to Folder "Review" |
| Replies diverted to another domain | Any Header · matches regex · ^Reply-To:.*@(gmail|outlook|hotmail)\. | Deliver to Folder "Review" |
The last two rules target specific attacks: fake cPanel and Webmail emails asking for the password with a "mailbox full" excuse, and BEC fraud, which diverts replies to the attacker's free account. Check the folder for the first few weeks: real suppliers and customers use Gmail too.
In a rule with several conditions, cPanel lets you choose between "and" and "or". For the manager impersonation rule you need "and": the name appears and the domain isn't yours.
What filters can't do
cPanel filters are useful for one-off cases, but they have clear limits:
- They don't inspect attachments. The "Body" condition only sees the start of the message, so it can't detect a dangerous file. That is what Exim's attachment filter is for.
- They don't follow links. A rule can't tell whether a link leads to a fake login page.
- They don't verify the sender. "From contains @bank.com" also matches an email spoofing the bank. Use SPF, DKIM and DMARC for that.
- They don't scale. Every new attack needs another rule, and old rules stay there catching false positives years later.
- Attackers use them too. Whoever steals a password often creates a filter that forwards or hides messages. Check an account's filters if you suspect it was compromised.
The Exim system filter (for administrators)
As the server administrator you can apply a rule to all mail without going into each account. Exim uses a system filter file, /etc/cpanel_exim_system_filter by default. Don't edit that file: cPanel replaces it on updates. Copy the original, add your rules at the end and point the System Filter File option in the Filters tab to the copy.
# Example: tag the subject of outside mail that uses your manager's name
if $header_from: contains "First Last"
and $header_from: does not contain "@yourcompany.com"
then
headers add "X-Warning: external sender using an internal name"
headers remove "Subject"
headers add "Subject: [EXTERNAL] $h_subject:"
endifTest the filter before enabling it with exim -bF filter-file < message.eml, which shows what it would do without delivering anything. A syntax error in the system filter can stop delivery for the whole server.
When filters are no longer enough
If you add rules for a different attack every week, the problem is no longer about rules. Bulk spam is better stopped by RBLs and greylisting (Exim antispam settings in WHM), and targeted phishing needs a filter that analyzes links, attachments and impersonation in every message. We compare the options in cPanel antispam.
Frequently asked questions
How do I block an email address or a domain in cPanel?
In cPanel › Email › Global Email Filters, create a rule "From · contains" with the address, or "From · ends with" with the domain, and the action "Discard Message" or a review folder. It applies to every account in that cPanel account.
What is the difference between global and account filters?
Global filters affect all mail received by the cPanel account, in every mailbox. Account filters affect only that mailbox, and users can create them themselves from Webmail.
Why isn't my filter working?
Most often the condition doesn't match exactly: the From field includes the display name and the < > signs. Use "contains" instead of "equals" and test the rule with the Filter Test tool.
Do cPanel filters help against phishing?
They help against specific campaigns you already know, such as a repeated subject. They don't catch new phishing, because they don't analyze links or verify the sender.
Antispam and antiphishing for your whole cPanel server
Instead of one rule per attack, Clisec analyzes every inbound message on your cPanel server and blocks phishing, BEC fraud and malware, with quarantine and per-user release.