Setup Email Filter

You can setup email spam filters to block unwanted email messages. What is Spam? There are many definitions of spam, but generally it is define as:

Spam is junk mail sent electronically, email spamming has been in existent since the beginning of Internet. Email spam filters is one way of scanning your email messages to block or delete unwanted email messages based on criteria set. You can block email messages of different nature. Email message meeting the filtering rules can either be deleted automatically or direct to another email account or pip to a programming script for further processing. These email spam filters are pretty flexible - there are some examples given below after the how-to instruction. Please note that email spam filters are cumulative and each messages are scan to match each of the filtering rules sequentially.

Info on spam :

Also check on another method of handling spam with Spam Assassin.

To setup email spam filter:

  1. Click Email Filtering link in the Cpanel hosting account control panel Mail option.

  2. Click Add Filter link to add a new email filter.

  3. Select a required header field in the drop-down list. These are the email headers found in any email message.

  4. Select a desired filter action in the drop-down list below. This action will be executed when there is a match of text entered in the third field with the target email being scanned.

    • equals - an exact match to the text, i.e "Loan" will block messages with the word "Loan" found the message.

    • matches regex - allow a broader matching of the text based on regular expression rules. Regular expressions are a little technical but powerful if you can master it. However, in most cases you may not need regular expression filters. If you are interested to know more, you can check on the following tutorials - Guide on using Regular Expressions and Learn How to Use Regular Expressions.

    • contains - broad match criteria. For example, entering "porn" will block "porn" as well as "pornography" because the text "porn" is found in the word "pornography" as well .

    • begins with - match when the text is found at the beginning of a word. For example, enter the text "porn" can block "porn" (whole word) and "pornography" (start with the word "porn") but not "teenporn" ("porn" is found at the end).

  5. Enter the text to filter in third field. Please note that this text is case sensitive.

  6. Enter the destination for the email messages matching the filtering rule in Destination text field. There are three options:

    • Discard the email or send to trash - Enter Discard in the destination text field.

    • Send to another email account - Enter the email account of which you want them to send to.

    • Send to a script - Enter the full path to the script.

  7. Click Activate button to enable this email spam filtering rule.

Some filtering Example:

  • To direct all email messages from "", you shuld enter: From, equals,,

  • To remove all email messages from domain, enter: From, contains,, Discard

  • To discard all pornography related messages, enter: Any Header, contains, porn, Discard

  • To delete email messages marked by Spam Assassin as spam, enter: SpamAssassin Spam Header, begins with, yes, Discard

Click to display image


Delete an email spam filter rule