Introduction
Spam Experts provides inbound and outbound email filtering services that help improve email security, spam protection, and mail delivery reliability. In a cPanel/WHM environment, administrators can configure Exim to route outgoing email traffic through Spam Experts filtering nodes (smarthosts).
This guide explains how to configure Exim in WHM so that all outgoing emails are relayed through the Spam Experts SMTP filtering server.
Prerequisites
Before proceeding, ensure the following requirements are met:
- A server running cPanel/WHM
- Root access to WHM
- Spam Experts SMTP hostname (smarthost)
- Valid DNS and mail configuration
- DKIM enabled for domains (recommended)
Implementation
Follow the steps below to route email traffic from the cPanel/WHM server through Spam Experts filtering nodes.
Step 1: Open Exim Configuration Manager
Login to WHM as the root user.
Navigate to:
WHM → Exim Configuration Manager
Then open:
Exim Configuration Editor
Step 2: Select “Advanced Editor”
Inside the Exim Configuration Manager, choose:
Advanced Editor
This allows custom Exim router and transport configurations to be added.
Step 3: Add Configuration to “Section: POSTMAILCOUNT”
Locate the section named:
Section: POSTMAILCOUNT
Add the following configuration.
Replace
SMARTHOSTwith your Spam Experts SMTP hostname.
smarthost_dkim:
driver = manualroute
domains = !+local_domains
require_files = "+/var/cpanel/domain_keys/private/${lookup{$sender_address_domain}dsearch{/var/cpanel/domain_keys/private/}}"
# Exclude null sender messages from relaying via the smarthost
condition = ${if or {{!eq{$sender_address}{}} {!eq{$sender_host_address}{}}}}
transport = remote_smtp_smart_dkim
route_list = $domain SMARTHOST::587
smarthost_regular:
driver = manualroute
domains = !+local_domains
# Exclude null sender messages from relaying via the smarthost
condition = ${if or {{!eq{$sender_address}{}} {!eq{$sender_host_address}{}}}}
transport = remote_smtp_smart_regular
route_list = $domain SMARTHOST::587
Step 4: Add Configuration to “Section: TRANSPORTSTART”
Locate the section named:
Section: TRANSPORTSTART
Add the following configuration:
remote_smtp_smart_dkim:
driver = smtp
hosts_require_tls = *
interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{}}}{}}
helo_data = ${if exists {/etc/mailhelo}{${lookup{$sender_address_domain}lsearch*{/etc/mailhelo}{$value}{$primary_hostname}}}{$primary_hostname}}
dkim_domain = $sender_address_domain
dkim_selector = default
dkim_private_key = "/var/cpanel/domain_keys/private/${lookup{$dkim_domain}dsearch{/var/cpanel/domain_keys/private/}}"
dkim_canon = relaxed
headers_add = "${perl{check_mail_permissions_headers}}"
remote_smtp_smart_regular:
driver = smtp
hosts_require_tls = *
interface = ${if exists {/etc/mailips}{${lookup{$sender_address_domain}lsearch*{/etc/mailips}{$value}{}}}{}}
helo_data = ${if exists {/etc/mailhelo}{${lookup{$sender_address_domain}lsearch*{/etc/mailhelo}{$value}{$primary_hostname}}}{$primary_hostname}}
headers_add = "${perl{check_mail_permissions_headers}}"
Step 5: Save the Configuration and Restart Exim
After adding the configuration:
- Click Save
- Allow WHM to rebuild the Exim configuration
- Restart the Exim service
You can also restart Exim manually via SSH:
systemctl restart exim
Verification
After completing the configuration:
- Send a test email from the server
- Review the Exim mail logs
- Confirm that the outgoing emails are routed through the Spam Experts smarthost
Common Exim log location:
/var/log/exim_mainlog
You can monitor logs using:
tail -f /var/log/exim_mainlog
Conclusion
Routing outgoing email traffic through Spam Experts filtering nodes enhances email security, spam filtering, and delivery reliability. By configuring Exim in WHM using custom routers and transports, administrators can ensure that all outbound mail is securely relayed through the Spam Experts infrastructure with DKIM and TLS support enabled.