Linux : How To send a copy of outgoing emails of a sender to another address with Exim/cPanel

By | December 20, 2018

This article will show you how to copy all outgoing email (transparently) of a specific user to another email account with Exim/cPanel.

There is no built-in feature to do so, but we will use the Exim highly flexible filter scripting capability that can be achieve from the command line.

1. Log into your cPanel server using SSH.

NOTE : In this example, we will assume that the source address is “outgoing.user@domain.tld” and the recipient address where we want to silently send a copy of all outgoing emails will be “recipient.user@domain.tld”.

2. Create and edit the following file using your favourite text editor :

/usr/local/cpanel/etc/exim/sysfilter/options/copy.outgoing_user_domain.tld

3. Copy and edit the following matching the sender and recipient addresses :

if first_delivery
and ("$h_from:" contains "outgoing.user@domain.tld")
and not ("$h_X-Spam-Checker-Version:" begins "SpamAssassin")
then
unseen deliver "recipient.user@domain.tld"
endif

4. In WHM, look at Exim Configuration Manager > Basic Editor > Filters

Look at the bottom, you should see a “Custom filter” matching “copy.outgoing_user_domain.tld”.

5. Ensure it is set to “On” and click “Save”.