Email filters are used to create rules for blocking spam emails. Some rules can be specified by the user to filter the incoming messages. Multiple rules can also be specified in one filter.Global email filters are used to filter all the incoming emails for a domain. It considers all the mail addresses within a domain for filtering the incoming messages. It ensures in receiving more mail and less spam. It is useful in re-directing mail or piping messages to a program and discarding spam. It is strongly recommended to use multiple, simple filters instead of one long/complex filter because mail filters can handle multiple small filters effectively than one long filter.
Steps to add a filter:
- Login to cPanel
- In Email section, click Global Email Filters
- Click create new filter
- In the field Filter Name, enter a name to the filter. The name should be unique and if you use same filter name, then the previous filter will be overwritten.
Then under Rules, set the rules for filtering messages with the help of two drop-down menus. In the first drop-down menu, select a message characteristic.
The list of message characteristics are
From – It includes the address from where the message was sent
Subject – It includes the subject line of a message
To – It includes the address to where the message was sent
Reply – It includes the address to which the reply will be sent
Body – It includes the content of the message
Any Header – It includes the header of a message
Any recipient – It includes the recipient of a message
Has not been previously delivered – Examines the messages that remain in a queue for delivery.
Is an error Message – Examines the error messages sent by an auto-response system.
List ID – It shows the account’s mailing lists.
Spam Status – This line begins with Yes or No whether Apache SpamAssassin has marked the message as spam.
Spam Bar – The content of the Spam Bar header is the Apache SpamAssassin generated for that message. The more plus signs (+) assigned to a message by Apache SpamAssassin, the greater the likelihood that the system marks the message as spam
Spam Score – It is an integer which represents the value of a total number of plus signs (+) in the Spam Bar.
In the adjacent drop-down menu, select an operator. The list of operators are
Equals – It matches the string exactly defined by the user
Matches regex – It matches a regular expression defined by the user
Contains – It contains the message defined by the user
Does not contain – It does not contain the string defined by the user
Begins with – The message begins with the defined string
Ends with – The message ends with the defined string
Does not begin – The message should not begin with the defined string
Does not end with – The message does not end with the defined string
Does not match – The message will not be same as the defined string
In this field, enter the filter or characteristic for any email account. This rule filters the emails from that account. The rules can be added and removed by clicking +/- buttons.
5. In the Actions menu, select an action for the created rule. The list of Actions are
Discard message – The system rejects the message with no failure notice.
Redirect to email – It redirects the message to another specified email address.
Fail with a message – The system rejects the message and sends a failure notice automatically to the sender.
Stop Processing Rules – It skips all the filter rules.
Deliver to folder – The messages will be delivered to a specific folder
Pipe to a program – The incoming messages will be sent to a specified program. When piping to a program, enter a relative path to the home directory.
6. Click create to initialize the filter.
Testing a Custom Filter:
In the Filter Test text box, type the test message and click Test Filter. It runs the test message and the result will be displayed on the next screen.