In order to route outbound mail through MXGuardian, you must configure Exim on your cPanel server to use a smarthost. There are two ways to do this depending on if you want to route all outbound mail or just outbound mail sent from certain domains.
Note: Make sure outbound filtering is enabled on your account before following this procedure.
Note: These options may not be available if you are using a shared server.
Option 1: Route all outbound mail to MXGuardian
- In the cPanel/WHM interface, search for "exim" and navigate to "Exim Configuration Manager". It may be located under "Service Configuration"
- On the Basic Editor tab, select the Mail tab:
- Enable "Smarthost Support" and enter "* smtp.mxguardian.net::587" into the box
Note: "Smarthost requires SMTP authentication" should be off because we will authenticate you by your IP address, not by username and password.
- Scroll to the bottom of the page and click "Save"
This will route all outbound mail on your server to MXGuardian.
Option 2: Use an outbound smarthost for certain domains only
If you are hosting multiple domains on your cPanel server and you would like to use an outbound smarthost for some domains and not others, first you need to create a text file that contains a list of the domains you want to route through the smarthost. Then you need to configure Exim to use that file as a lookup table.
In this example, we will need to create a file called /etc/smarthosts. The file should contain one line for each domain. For example:
domain1.com smtp.mxguardian.net::587
domain2.com smtp.mxguardian.net::587
anotherdomain.com smtp.mxguardian.net::587
Once you've created the file, follow these steps in cPanel/WHM:
- Open "Exim Configuration Manager"
- Before you make any changes, backup the current Exim configuration by going to the Backup tab, and clicking "Run Backup"
- Select the "Advanced Editor" tab. Search for the text "POSTMAILCOUNT" and then paste the following code into the box:
mxguardian_smarthost_dkim:
driver = manualroute
domains = !+local_domains
require_files = "+/var/cpanel/domain_keys/private/${sender_address_domain}"
transport = dkim_remote_smtp
route_data = ${lookup{$sender_address_domain}lsearch{/etc/smarthosts}}
mxguardian_smarthost:
driver = manualroute
domains = !+local_domains
transport = remote_smtp
route_data = ${lookup{$sender_address_domain}lsearch{/etc/smarthosts}}
Be sure to maintain proper indentation. It will look like this:
- Scroll to the bottom of the page and click "Save"
This will route outbound mail sent from certain domains to MXGuardian.
Troubleshooting
If you have any problems, or to see if the outbound relay is working, it may be helpful to review the Exim log file which is usually located at /var/log/exim_mainlog. A successful log entry looks like this:
Here's a breakdown of what each part means:
Part | Meaning |
2023-12-08 16:40:46 | Date & Time |
1rBduA-000fkL-0a | Exim queue ID |
=> | Indicates an outbound message |
receipient@example.com | Recipient Email Address |
R=mxguardian_smarthost_dkim | Router name |
T=dkim_remote_smtp | Transport name |
H=smtp.mxguardian.net [54.172.140.227] | Remote host name & IP address |
X=TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256 | Indicates that the message was encrypted and the cipher suite used |
CV=yes | Indicates the certificate was verified |
C="250 2.0.0 Ok: queued as 789F4470E63" |
The confirmation message received from the remote server |
To search the log file for a specific entry, use the `exigrep` command line utility. For example, if you sent a test message to "receipient@example.com", you would use this command to view the relevant log entries:
exigrep -l "recipient@example.com" /var/log/exim_mainlog
Additional Notes
- The POSTMAILCOUNT section must be used instead of ROUTERSTART for max hourly mail limits to be followed and used.
- The file name is not important. Some tutorials use `/etc/staticroutes` but that is typically for routing based on the recipient domain. Since we are routing based on the sender domain, we named the file `/etc/smarthosts` instead.
- These instructions were created using cPanel version 114.0.15.
Comments
0 comments
Please sign in to leave a comment.