cPanel User Level Filtering are filters that you can set within the cPanel control panel that will block or divert messages based on conditions that you set in the cPanel Email Filters settings. You can set conditions to target messages that contain a certain word or phrase, From, To, or based on subject. You can add multiple levels of email filters so that you can fine-tune precisely 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).
Step 1 - Click on the User Level Filtering icon
You will find the "Account Level Filtering" icon under the Mail section of the cPanel Control Panel as shown in the screenshot below:
Step 2 - On the Next Screen Click Manage Filters Next to the Relevant Email Address
On the next screen, you will see a list of email addresses you have on the account as well as the system email account. To setup cPanel User Level Filtering you will need to select the "Manage Filters" option next to the email address that you wish to setup Email Filtering for. See the screenshot below:
Step 3 - Create a New User Level Email Filter
Once you click on the Manage Filters link in Step 2, you will be taken to a page that shows your current filters, a test message that you can use to check your filters, as well as an option to create new email filters. Click the Create a New Filter button as shown below to create the new cPanel User Level Filter:
Step 4 - Configure the New Email Filter
This is where you enter all the details of your new email filter. You will need to designate a Filter Name, and then set the Option Rules, Operator Rules and then the Action Rules for each filter. You can have multiple Rules for each Filter to create a more accurate result.
- Filter Name - You will need to give your filter a name. The name you give cannot contain "Rule #" or "Converted Rule" as you can see from the above image.
Email Filter Option Rules:
- From - This is the "from" email address that you wish to match
- Subject - This will filter by the subject of the email
- To - This filters by the "To" email address
- Reply Address - This filters by the "Reply" email address
- Body - This will check the email body for any matches
- Any Header - This will check the headers of the email
- Any Recipient - This will check all the different recipients of the email
- Has not been previously delivered - This will only filter emails that are still in the servers email queue
- Is an error message - This will check the error message received by autoresponders , or email forwarders.
Email Filter Operator Rules:
- Equals - This will match identically the text entered
- Matches Regex - You can enter a Regular Expression here
- Contains - This will do a partial match of the specified string of characters
- Does not Contain - This will check whether the email does NOT have a partial match of the specified string of characters
- Begins with - This will check whether the Rule begins with the characters specified
- Ends with - This will check whether the Rule ends with the characters specified
- Does not begin with - This will check whether the Rule DOES NOT begin with the characters specified
- Does not end with - This will check whether the Rule DOES NOT end with the characters specified
- Does not match - This will check that it does not match the characters specified
Email Filter Action Rules:
- Discard Message - Deletes the message with no Failure message.
- Redirect to Email - Sends the email to another email address.
- Fail with Message - Deletes the email and sends a failure message.
- Stop processing rules - Does not run any filter rules.
- Deliver to
folder- Sends the email to a specified folder.
- Pipe to program - Sends the email to a program or script on the server.
If you choose to pipe the action to a program, the path used should be relative to your home directory. If the script the Perl or PHP interpreter, you should omit the /
#!/usr/local/bin/php -q -- For PHP
#!/usr/bin/perl -- For Perl.
Adding Multiple Rules
You can configure each Filter with multiple rules so that you can select something that "begins
Due to the way the mail server works (
Using User Level Filters in conjunction with Spam Assassin
You will see at the bottom of the page some hints how to configure this to work with Spamassassin. Fortunately, we have created a very detailed Spamassassin tutorial which will take you through all the steps to configure this.
Step 5 - Click "Create" to create the filter
The final step is to click the Create button. You will see a confirmation message once you do so as shown in the screenshot below:
Testing your User Level Filters
On the main User Level Filter Screen, you will see an option to "Filter Test." You will see a preset simple email message that you can modify to test your rule. In our example below, we set a filter to delete any emails from "[email protected]". You can see we added this to the From section in the example:
Once you click "Test Filter" you will see the Filter Trace results. In our example, it shows a match:
And that is all there is to it. It may seem a little complicated, but basic filtering is very easy to configure.