Introduction

cPanel and Exim allow administrators to configure advanced email routing and filtering options. One such configuration is creating a blind carbon copy (BCC) of all incoming and outgoing emails for a specific domain and forwarding them to another email address.

This setup is useful for:

  • Email monitoring and archiving
  • Backup of business communications
  • Compliance and auditing purposes
  • Centralized email tracking

This guide explains how to configure Exim in cPanel/WHM to forward copies of all incoming and outgoing emails for a domain to another mailbox.


Prerequisites

Before proceeding, ensure you have the following:

  • Root or sudo access to the server
  • WHM administrative access
  • cPanel server with Exim installed
  • Basic knowledge of Linux command line
  • A destination email account for receiving forwarded copies
  • SSH access to the server

Important:
The destination email address should NOT belong to the same domain being monitored. Otherwise, it may create a mail forwarding loop.


Steps to Configure Email Forwarding in Exim

Step 1: Create a Copy of the Existing Exim System Filter

Login to the server via SSH and navigate to the /etc/ directory.

Run the following command:

cp /etc/cpanel_exim_system_filter /etc/cpanel_exim_system_filter2

This creates a backup copy of the current Exim system filter configuration.


Step 2: Edit the New Exim System Filter

Open the newly created filter file using a text editor such as nano or vi.

Example:

nano /etc/cpanel_exim_system_filter2

Add the following lines at the bottom of the file:

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

if $sender_address: contains "domain.com"
then
unseen deliver "user@domain.com"
endif

Step 3: Replace Domain and Email Address

Update the following values:

PlaceholderReplace With
domain.comYour domain name
user@domain.comDestination email address

Example:

if ("$h_to:, $h_cc:, $h_bcc" contains "example.com")
then
unseen deliver "backupmail@gmail.com"
endif

if $sender_address: contains "example.com"
then
unseen deliver "backupmail@gmail.com"
endif

Step 4: Update Exim Configuration in WHM

  1. Login to WHM
  2. Navigate to:
    WHM → Exim Configuration Manager → Advanced Editor
  3. Locate the System Filter File
  4. Change the path to:
/etc/cpanel_exim_system_filter2
  1. Save the configuration

Step 5: Restart Exim Service

Restart the Exim mail service for changes to take effect.

/scripts/restartsrv_exim

or

systemctl restart exim

Verification

After configuration:

  • Send a test email to the monitored domain
  • Send an outgoing email from the monitored domain
  • Verify that copies are received at the destination email account

Important Notes

  • The unseen deliver option sends a copy without affecting normal mail delivery.
  • Always keep a backup of the original Exim filter file before making changes.
  • Incorrect filter syntax may stop Exim mail processing.
  • Avoid forwarding to the same domain to prevent infinite mail loops.

Conclusion

Using Exim system filters in cPanel/WHM, administrators can configure automatic blind copies of all incoming and outgoing emails for a specific domain. This setup is useful for monitoring, auditing, and maintaining email backups while ensuring original mail delivery remains unaffected.

Leave a Reply