Monitor outgoing emails in cPanel exim

In cPanel WHM, Main > Service Configuration > Exim Configuration Editor:

Under Filters, check "System Filter File" location, usually at "/etc/cpanel_exim_system_filter".

Edit the file:

Just below (this should already exist):

if not first_delivery
then
  finish
endif

Add the filter:

# Monitor outgoing emails from domain.tld
if first_delivery
   and ("$h_from:" contains "@domain.tld")
   and ("$h_from:" does not contain "youremail@")
then
   unseen deliver "monitor@domain.tld"
endif

Save changes and restart exim:

# /etc/init.d/exim restart

If you need to monitor both outgoing and incoming emails:

# Monitor both incoming and outgoing emails.
if first_delivery
   and ("$h_to:, $h_cc:" contains "@domain.tld")
   or ("$h_from:" contains "@domain.tld")
   and ("$h_to:, $h_cc:, $h_from:" does not contain "youremail@")
then
   unseen deliver "monitor@domain.tld"
endif

This will silently forward all mails except yours' to the monitoring email address provided.

Note: You should probably create a custom filter file like "/etc/cpanel_exim_system_filter_custom", otherwise cPanel updates will overwrite the changes.

Comment