Please keep in mind that this guide provides a very basic example. The process of creating and customizing Exim filters is one that must be performed by a systems administrator with the skills, training, and expertise required to do so for you. This guide is only provided as a courtesy and cPanel Support is not able to provide assistance with using or modifying this example to fit your specific needs.
In order to prevent a domain from receiving messages from any outside source, you can use the Global Email Filters icon in cPanel to do so.
1. Login to cPanel
2. Click on the Global Email Filters icon
3. Click the blue "Create New Filter" button
4. Create a rule with the following conditions. Please replace "exampledomain.tld" with your desired domain.
From - Does Not Contain - exampledomain.tld - Discard Message
5. Click the blue "Create" button
You'll notice that this only works for incoming messages.
In order to enforce this on outgoing messages use the following steps:
1. Login to SSH or Terminal as the root user
2. Create the following file:
3. Place the following contents in this file. Please replace exampledomain.tld with your domain.
if $header_from: contains "exampledomain.com" and $header_to: does not contain "exampledomain.com" then fail text "Messages cannot be sent from $header_from to external domains. $header_to is not an internal domain." seen finish endif if not first_delivery then finish endif
4. Login to WHM as the root user
5. Navigate to: Home »Service Configuration »Exim Configuration Manager
6. Click on the "Filters" tab
7. Scroll to the bottom and look for the name of your custom filter. It will be prefixed with "Custom Filter:"
8. Enable that filter
9. Click the blue "Save" button
IMPORTANT: This filtering example is very rudimentary. If you need a more advanced configuration that handles CC, BCC, or any other additional situations, you must reach out to a systems administrator with the skills, training, and expetise required to do so for you.
You can learn a great deal about how to make the custom filters do what you want by reviewing the Exim documentation:
There are also some discussions about this topic in our forums:
If your issue still has not been addressed by this guide or the existing forums posts, you may also consider creating a new forums post for further assistance.