Introduction
Sometimes a user has a need to have more robust filters than what can be set in cPanel itself. In this case, a user wants a variable match to deliver the email to one address and then continue processing so if it matches and delivers to another email address and then ultimately to the address sent. This can be done using unseen in a custom Exim filter.
Procedure
First a file needs to be created in /usr/local/cpanel/etc/exim/sysfilter/options/ and in this how-to that file will be /usr/local/cpanel/etc/exim/sysfilter/options/custom.
In that file the following custom Exim filter will check if the body contains HIGHLANDCBPROJECT and deliver an email to user@anydomain.com but because unseen is used the email continues onward and checks if the body contains HIGHLANDCBANTENNAPROJECT and if it does the email is delivered to anotheruser@anotherdomain.com and because that is set to unseen the email continues again and delivers to the intended sent address.
if
$message_body contains "HIGHLANDCBPROJECT"
then
unseen deliver "user@anydomain.com"
endif
if
$message_body contains "HIGHLANDCBANTENNAPROJECT"
then
unseen deliver "anotheruser@anotherdomain.com"
endif
More documentation from Exim can be found at: Exim Filters
Once the filter file is created the Exim configuration needs to be rebuilt and Exim restarted. This is done by doing the following:
/scripts/buildeximconf
/scripts/restartsrv_exim