How to Route Traffic from a cPanel/WHM Server to Spam Experts Filtering Nodes

  WHM

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:


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 SMARTHOST with 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:

  1. Click Save
  2. Allow WHM to rebuild the Exim configuration
  3. Restart the Exim service

You can also restart Exim manually via SSH:

systemctl restart exim

Verification

After completing the configuration:

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.

LEAVE A COMMENT