Copy Outgoing Email on a cPanel Server with Exim
Posted by Vanessa | Tagged under exim,howto | Posted on March 2, 2011
15
A common request we get is how a user can automatically BCC outgoing email to another address. This is most often requested by law firms that need to be able to retain copies of communication. Forwarding incoming email is easy – there’s already a section in cPanel for it. However, if you want to forward outgoing email there’s a small twist.
First, go to WHM > Exim Configuration Editor, then click “Advanced Editor” at the bottom. Don’t make any changes, just click “save”. This should create a file on the server called /etc/exim.conf.local. From command line as root, you’ll need to edit /etc/exim.conf.local and add some options to the @CONFIG@ and @TRANSPORTSTART@ sections. The end result would look like this (plus any edits you may have already made):
@AUTH@
@BEGINACL@
@CONFIG@
system_filter_directory_transport = local_copy_outgoing
@DIRECTOREND@
@DIRECTORMIDDLE@
@DIRECTORSTART@
@ENDACL@
@RETRYEND@
@RETRYSTART@
@REWRITE@
@ROUTEREND@
@ROUTERSTART@
@TRANSPORTEND@
@TRANSPORTMIDDLE@
@TRANSPORTSTART@
local_copy_outgoing:
driver = appendfile
delivery_date_add
envelope_to_add
return_path_add
group = cpaneleximfilter
user = cpaneleximfilter
mode = 0660
maildir_format = true
create_directory = true
Now, make a copy of the existing system filter file to a custom location, so cPanel updates don’t mess with it:
cp /etc/cpanel_exim_system_filter /etc/cpanel_exim_system_filter_custom
Edit /etc/exim.conf.localops and change the “systemfilter” option to match our new file:
systemfilter=/etc/cpanel_exim_system_filter_custom
Now, open /etc/cpanel_exim_system_filter_custom and add the following block of code to the end of the file:
if $header_from: contains "@senderdomain.com"
then
unseen deliver "other@emailaddress"
endif
Replace the blue text with the sender domain (or email address) and the email address that outgoing mail should be copied to.
Apply these new settings to the exim.conf and restart:
/scripts/buildeximconf
service exim restart
Now when you send email from the email address or domain specified in the filter file, it will be copied to the other email address.
Related posts:





sending...

What will happen when the WHM is upgraded? Will it retain the settings or overwrite it?
As long as you follow the instructions, the settings will remain during updates
In your example, it only copies if it matches a certain “FROM domain”
What if we wanted to base the rule on a user?
I want to copy all outgoing emails, even those sent by PHP’s mail() function without a FROM
so the pseudo-code is :
if ( user = someuser )
then
unseen deliver “other@emailaddress”
endif
Is this possible?
And is it possible to create a “copy all outgoing emails”. So ALL outgoing emails from the servers, even by PHP’s mail(), will be copied ?
Thanks in advance Vanessa.
Roy
[...] http://www.thecpaneladmin.com/copy-outgoing-email-on-a-cpanel-server-with-exim/ [...]
Thanks Vanessa.
With this method, I can set the rules for incoming email, too? How I can?
Simply create a forwarder for the address within cPanel or /etc/valiases/$domain
### START OF OUTGOING + INCOMING MAIL FORWARDING ###
### domain tappeddomain.com ###
if first_delivery
and (“$h_to:, $h_cc:” contains “@tappeddomain.com”)
or (“$h_from:” contains “@tappeddomain.com”)
then
unseen deliver “tappeddomain@gmail.com”
endif
### END OF OUTGOING + INCOMING MAIL FORWARDING ###
Vanessa,
I just update cPanel from 11.28 into 11.30
and on /etc/exim.conf.localops
systemfilter no longer point to /etc/cpanel_exim_system_filter_custom
instead it go to
systemfilter=/usr/local/cpanel/base/eximacl/antivirusandspam.exim
what should I do?
and I get this message after cPanel update complete:
==================================
cPanel was unable to automatically merge your Exim configuration with the new settings that shipped
with the build you have installed (11.30.4 (build 6)) because you have a custom or broken configuration which
cannot be automatically configured.
Your current acl configuration is not compatible with this version of cPanel.
This version of cPanel has an update that is critical, and must be installed to keep email functional on your system.
To avoid any mail downtime, we have replaced the acl configuration with the default configuration.
A copy of the old configuration has been saved to to /etc/exim.conf.local.1318092123.before_acl_version_8.2
If you wish to preserve the old acl configuration, you need to manually merge your configuration
with the new configuration settings.
I did all the above things but its not happening.
Please help me more
Will this work with BCC? :)
Can I send the BCC through another route? All my email is routed through an ESP. I would like to route the BCC directly.
Hi all,
My webhosting company uses SpamAssassin, can someone help me to achieve the same thing “Copy Outgoing Email on a cPanel Server with SpamAssassin”
If it can’t be done is there any other way, because it seems like my hosting company don’t have qualified ppl to help, or I am not getting to them clearly.
Please support.
thanks.
The server we tested this procedure on also uses SpamAssassin, and it worked. Keep in mind that the SpamAssassin implementation on cPanel servers only scans incoming mail – outgoing mail is not affected.
i think /etc/exim.conf.localops is misspelled the correct one is /etc/exim.conf.localopts
[...] Copy Outgoing Email on a cPanel Server with Exim [...]