This guide is not aimed at being a complete how-to on modifying the Exim System filter, as there are various rules that can be written and modified. In this example, we'll focus on preventing specific users from sending to specific providers such as Google, or Yahoo. By editing your Exim System filter at
/etc/cpanel_exim_system_filter, you can add and remove rules to help you filter the mail as you desire.
- Start by logging into the cPanel server via SSH.
- Next, copy the system filter to a new file. You can name this anything you would like, for example:
cp -a /etc/cpanel_exim_system_filter /etc/cpanel_exim_system_filter_custom
- Using your favorite editor, such as vi/vim/nano, modify
/etc/cpanel_exim_system_filter_customand use the following as a template:
#Custom exim block for specific users $date
if $header_from: contains "email@example.com" or $header_from: contains "firstname.lastname@example.org" and
$header_to: contains "@gmail.com" or $header_to: contains "@outlook.com" or $header_to: contains "@hotmail.com" or $header_to: contains "@yahoo.com"
fail text "This message is not able to be sent to the destiation due to your server configuration. Please speak with your server administrator."
- Once completed, log in to your WHM, and navigate to Home » Service Configuration » Exim Configuration Manage » Filters.
- Replace the system filter with your custom filter that you modified earlier.
- Click Save.
To verify this is working, log in to your webmail or email client and try sending an email to one of the blocked domains. You should receive a bounce with the message, "This message is not able to be sent to the destination due to your server configuration. Please speak with your server administrator."
You can also use the following to verify it was filtered through the Exim mainlog:
exigrep " cancelled by system filter:" /var/log/exim_mainlog