Introduction
The following provides an example of how you can use an Exim system filter in cPanel to forward all outbound mail for an email account.
Filters and forwarders that can be managed directly within a cPanel account are only applied to incoming messages, so this method is useful if you need to affect outbound messages.
Please keep in mind that cPanel is not able to provide support for customizing the specific contents of your Exim filters. If you need help crafting a custom filter, you should reach out to a systems administrator with the skills, training, and expertise required to do so for you.
Procedure
1. Login to the server via SSH or Terminal as the root user
2. Create a filter file with the touch command:
touch /usr/local/cpanel/etc/exim/sysfilter/options/fowardOutbound.conf
3. Customize the following example filter and put it into the file that you just created:
if ("$h_from:" contains "from@domain.tld")
then
## The following will make it so that the original recipient is skipped and
## and only recipient@domain.tld will recieve the message
deliver "recipient@domain.tld"
## If you add the word unseen in front, the message will be forwarded to
## recipient@domain.tld as well as delivered to the original recipient.
## For example, you would remove the above deliver line and replace it with:
## unseen deliver "recipient@domain.tld"
endif
4. Rebuild the exim configuration with the following command:
/scripts/buildeximconf
As long as the filter file is enabled (it is by default when you first create it) cPanel will copy your custom filter in to the system filter file at: /etc/cpanel_exim_system_filter
5. Restart Exim with the following command:
/scripts/restartsrv_exim
To disable or enable your custom filter use the following steps:
1. Login to WHM as the root user
2. Navigate to: Home »Service Configuration »Exim Configuration Manager
3. Click on the Filters tab
4. Look for your filter prefaced by "Custom Filter"
5. Enable or disable it
6. Click the blue Save button