BCC to all emails in exim cPanel|Copy all outgoing emails on exim

Date posted: 14-02-2018

In this post, we will explain how to keep all outgoing Emails to particular mail account. Note that the email box which we will be setup will receive all the mails irrespective of to address. So, it would be good if that mail box can have unlimited storage.

Assumptions:

  1. Exim Mailserver
  2. Email account(used as BCC email)
  3. Server root access

Implementation:

Login to the server using SSH.

Copy default system filter config file /etc/cpanel_exim_system_filter

cp /etc/cpanel_exim_system_filter /etc/cpanel_exim_system_filter_bcc

Edit the file with the following content.

vi /etc/exim.conf.localopts

systemfilter=/etc/cpanel_exim_system_filter_bcc

Open the file  /etc/cpanel_exim_system_filter_bcc and add the below content.

vi/etc/cpanel_exim_system_filter_bcc

if ("$h_to:, $h_cc:, $h_bcc" contains "domain.tld")
then
  unseen deliver "email@domain.tld"
endif

if $sender_address: contains "domain.tld"
then
unseen deliver "email@domain.tld"
endif

Replace the domain.tld with your own domain.

Rebuild the exim configuration.

/scripts/buildeximconf

Restart the exim service.

systemctl restart exim

Verify the log for the domain.tld and we can see sample log file as below which indicates that the mails are being bcc to email@domain.tld

grep email@domain.tld /var/log/exim_mainlog

2018-02-14 11:41:35 1elxxxxx -> email@domain.tld <system-filter> R=smarthost_dkim T=remote_smtp_smart_dkim H=xxxxxx [xx.xx.xx.xx] X=TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256 CV=yes  C="250 OK id=1elxxxxx"

Leave a Reply