Block Outgoing Mails For Particular Domains Using Cpanel Filter Rule

Block Outgoing Mails For Particular Domains Using Cpanel Filter Rule

We can block outgoing mails for one particular email account or domain using the cpanel filter rule.

Steps to disable mail for particular Domain

Cpanel Default filter file. /etc/cpanel_exim_system_filter

1. Copy the cpanel filter file, using default can be replaced on future cpanel update.
cp -rp /etc/cpanel_exim_system_filter /etc/cpanel_exim_system_filter_EDITED

2. Set the copied cpanel filter file on exim configuration file.
vi /etc/exim.conf

Find the line — > system_filter = /etc/cpanel_exim_system_filter

Replace it with — > system_filter = /etc/cpanel_exim_system_filter_EDITED

3. Paste this rule on the bottom of the filter file.
if first_delivery
and
$h_from: contains “@DOMAIN_NAME”
then
fail text ”Sorry You are not allowed relay emails from the server.”
seen finish
endif

Replace the word “DOMAIN_NAME” with the exact domain name to which you want to disable outgoing mail.


4. Restart exim to take effect of new settings.
/scripts/restartsrv_exim

You can use this filter rule to block both incoming and outgoing mails for particular domain.

KishanRam