Published on: May 18, 2019 by Albert Reilly
Using a custom filter with custom rules to discard emails considered spam across the whole server.
Exim uses a global file to set filters for all the accounts in a server, but they contain just some default rules. We can add new rules to this file and make filters to work across the server.
Filters are usually setup using cPanel>>Global Filters but this is used only for filtering mails to that particular account. The filters created via cPanel is saved in /etc/vfilters directory.
So we can use the Global Filter in cPanel to generate these rules and then add these to the global file so that the change is available across the server. Below I will explain in detail on how to do this.
Below I will explain how the rules for filtering were created.
1. Log into cPanel >> Global Filters
2. Create a Filter
3. test1 filter for attaining ‘Spam status -> begins with -> Yes -> Discard‘
4. test2 filter for attaining ‘Spam bar -> contains -> ++++++ -> Discard‘
Now the rules created for these filters in the file /etc/vfilters/example.com is fetched and it is as below.
Now the above snippet for filtering mails is now made global across the server by adding it to the file /etc/cpanel_exim_system_filter which is the file that exim checks for filtering contents.
Goto WHM >> Exim Configuration Manager and click Filters
Now we can see the used default file as below.
Now we make a new custom file via backend for this so that the filters are preserved even after any updates.
We copy the default file to a new file to keep the existing settings as well and then add the custom rules to it.
Now we add the above snippet to the newly created file ‘/etc/cpanel_exim_system_filter_custom‘
Then the Exim Configuration Manager setting is changed to use this new file as below.
Now the filter is made global across the server.
Hope you enjoyed !
Category : cPanel, Email service