Custom Account and User Level Filters
Account and user level filters control how your incoming email is handled, helping to ensure that you receive more mail and less spam. cPanel allows you to manage filters for each email account on your domain. This can be useful for discarding spam, redirecting mail or piping messages to a program.
Adding an Account or User Level Filter
To create an account or user level filter:
Log into cPanel.
In the Mail section, click Account Level Filtering or User Level Filtering according to your preference.
For a user level filter, click Manage Filters next to the email address for which you wish to add a filter.
- Click Create a New Filter.
- In the Filter Name field, enter a name for the filter.
- In the first drop-down menu under Rules, select a message characteristic.
- From - address from which the message was sent
- Subject - the subject line of the message
- To - address to which the message was sent
- Reply Address - address to which the reply will be sent
- Body - body or content area of the message
- Any Header - a header of the message
- Any recipient - a recipient of the message
- Has not been previously delivered - affects messages still in queue for delivery
- is an error message - affects error messages received from an auto-response system
- Spam Status - the status SpamAssassin has been conferred on the message; it begins with either "Yes" or "No."
- Spam Bar - the content of the Spam Bar header that SpamAssassin has generated for this message. This header contains plus (+) signs to denote the likelihood that the message is spam; more plus signs means the message is more likely spam.
- Spam Score - the overall spam score assigned to the message by SpamAssassin, expressed in digits.
- In the adjacent drop-down menu, select an operator.
- equals - exactly matches the string you define
- matches regex - matches a regular expression you define
- contains - contains the string you define
- does not contain - does not contain the string you define
- begins with - begins with the string you define
- ends with - ends with the string you define
- does not begin - does not begin with the string you define
- does not end with - does not end with the string you define
- does not match - is not equal to the string you define
The following options are only applicable when the Spam Score option is selected:
- is above (#s only) - scores greater than the number you define will be subject to the action selected
- is not above (#s only) - all scores equal to or less than the defined number will be subject to the action selected
- is below (#s only) - all scores below the defined number will be subject to the action
- is not below (#s only) - all scores greater than or equal to the specified number will be subject to the action
- In the field below, enter the filter or characteristics you wish to use as the filter. (Regular expressions are accepted.)
This rule will target any emails from the sender firstname.lastname@example.org.
- You can add and remove rules by clicking the +/- buttons.
- In the Actions drop-down menu, select an action for the rule you created.
- Discard message - destroys the incoming message with no failure notice
- Redirect to email - redirects the message to another email address that you specify
- Fail with message - discards the message and automatically returns a specified failure notice to the sender
- Stop processing rules - skips all filter rules
- Deliver to folder - deposits the message into a specified folder
- Pipe to a program - sends the incoming message to a program you have specified
When piping to a program, you should enter a path relative to your home directory. If the script requires an interpreter, such as Perl or PHP, you should omit the /usr/bin/perl or /usr/local/bin/php portion. Make sure your script is executable and has the appropriate hashbang.
- #!/usr/local/bin/php -q -- For PHP
- #!/usr/bin/perl -- For Perl.
- Click Create to initialize the filter.
Testing a Custom Filter
If you have a filter created, you can test it by :
From cPanel, in the Mail section, click Account Level Filtering or User Level Filtering.
For a user level filter, click Manage Filters next to the email address you'd like to test.
- In the Filter Test text box, type a test email message and click Test Filter. (Be sure to include the characters or words that you have set your filter to catch.)
- When the test is run, the next screen should display the results. This screen summarizes the actions taken by the filter. It is important to read over the data to ensure that the filter produces the desired result.