How to Create cPanel Email Filters

Email filters in cPanel help you control what email you receive including to help reduce spam. Learn how to set up cPanel email spam filters with this detailed guide.

You can set cPanel Email filters from within the cPanel control panel dashboard. They can either be set Globally or on a per email address basis. They provide you with another level of control over what emails you receive and are particularly beneficial for helping prevent spam emails.

With the email filters, you can set conditions to target messages that contain a specific word or phrase, From, To, or based on subject. You can add multiple levels of email filters so that you can precisely fine-tune what you wish to happen with the email received.

The emails that you filter via cPanel User Level Filtering can be discarded, sent to another email address, or delivered to a program (such as a support ticketing system, although cPanel email forwarding is often used for this purpose).

Email filters in cPanel can be set either on a user-level or globally. I’ll cover these in turn, even though they are virtually identical apart from the first couple of steps.

I will then look at a couple of practical examples.

How to Setup cPanel Email Filters for an Individual Email Address

How to Setup cPanel Email Filters for an Individual Email Address

How to Setup cPanel Global Email Filters

How to Setup cPanel Global Email Filters

Example: Using Multiple Email Filters with SpamAssassin

I have created a very detailed SpamAssassin tutorial which goes in detail all the steps required to configure SpamAssassin to create a spam filter properly. It includes how to set the SpamAssassin Score (Spam Threshold Score), move spam to junk folder (Spam Box), auto-delete, and add emails to either the whitelist or blacklist.

When you create rules within the Spam Filters section, it will automatically create Global Email Filters. It can be easier to configure basic SpamAssassin rules through this interface.

There are times when you want more granular control over when SpamAssassin triggers an action. For example, you may want random newsletters you receive to be marked as spam unless the body matches “keyword”. This may be a particular topic you are interested in.

I will now make a SpamAssassin rule that satisfies the following conditions:

  • Spam Score is less than 4.
  • The body does not contain the keyword “SEO”.
How to Use Multiple Email Filters with Spam Assassin

Using cPanel Email Filter Wildcards

You can use wildcards in Spam Filters by using Regex. Providing a full breakdown of how Regex works is beyond the scope of this tutorial.

However, I will provide you with some basic examples to get you started:

Anchors - ^ and $

  • ^The - matches any string that starts with “The”
  • end$ - matches a string that ends with “end”
  • ^The end$ - exact string match
  • filtering - matches any string that has the text “filtering” in it

Quantifiers - *, +, ?, and {}

  • abc* - matches a string containing “ab” followed by “zero” or more “c”
  • abc+ - matches a string that has “ab” followed by one or more “c”
  • abc? - matches a string that has “ab” followed by zero or one “c”
  • abc{2} - matches a string that has “ab” followed by 2 “c”
  • abc{2,} - matches a string that has “ab” followed by 2 or more “c”
  • abc{2,5} - matches a string that has “ab” followed by 2 up to 5 “c”
  • a(bc)* - matches a string that has “a” followed by “zero” or more copies of the sequence “bc”
  • a(bc){2,5} - matches a string that has “a” followed by 2 up to 5 copies of the sequence “bc”

OR operator - | or []

  • a(b|c) - matches a string that has “a” followed by “b” or “c”
  • a[bc] - matches a string that has “a” followed by “b” or “c”

Grouping - ()

  • a(bc) - parentheses create a group with the value “bc”

For more detailed examples see this cheat sheet.

Example Email Filter using a Wildcard

Let’s take the example I used previously configuring a SpamAssassin filter that contained several rules. I can simplify the rules match field as follows:

How to Use Email Filters with Wildcards

How to Test your Email Filters

On the main Email Filter Screen, you will see an option to “Test Filter.” You will see a preset simple email message that you can modify to test your any of your Filters.

In my example below, I set a filter to delete any emails from “someone@spam.com.”

How to Test Email Filters in cPanel
Jonathan Griffin. Editor @ The Webmaster

Editor, SEO Consultant, & Developer.

Jonathan Griffin is The Webmaster's Editor & CEO, managing day-to-day editorial operations across all our publications. Jonathan writes about Development, Hosting, and SEO topics for The Webmaster and The Search Review with more than nine years of experience. Jonathan also manages his own SEO consultancy, offering SEO developer services. He is an expert on site-structure, strategy, Schema, AMP, and technical SEO. You can find Jonathan on Twitter as @thewebmastercom.

Read more about Jonathan Griffin on our About Page.