cPanel/WHM Smarthost Setup

Configure cPanel/WHM (Exim) to use a Smarthost

Step 1: In the cPanel/WHM interface search "exim" and navigate to the Exim Configuration Manager.

- Select the Advanced Editor tab.

Step 2: Add (copy & paste) the following entry to the "ROUTERSTART" section:

smarthost_route:
driver = manualroute
domains = !+local_domains
transport = remote_smtp
route_list = * smarthost.yourdomain.com
		

cPanel/WHM Exim Smarthost Configuration

Replace "smarthost.yourdomain.com" with the hostname of your outbound Smarthost system.

The above entry will route email for all domains on the server with the exception of local email to the Smarthost.

If you need to use an alternative outgoing port other than the usual SMTP port 25 you should change the "route_list" as follows if for instance you wish to relay outbound email via port 587:

route_list = * smarthost.yourdomain.com::587

Step 3: Scroll down to the bottom of the screen and select the "Save" button to activate the configuration.

Step 4: Check the Exim logs (usually /var/log/exim_mainlog) and the Mail Log Viewer on the outbound Smarthost to make sure that email is being routed properly.

Route emails for only specific domains to a Smarthost:

Step 1: In the cPanel/WHM interface search "exim" and navigate to the Exim Configuration Manager.

- Select the Advanced Editor tab.

Step 2: In the "Section: CONFIG" scroll down to the bottom and locate and select the "Add additional configuration setting" button.

- Once selected a drop down selection field and associated text field to the right of this will appear above the Add additional configuration setting button.

- Enter "hostlist smart_hosts" in the left hand side text box and "lsearch;/etc/smarthosts" in the right hand side box as in the following example:

cPanel/WHM Exim Smarthost Configuration for specific domains

Setp 3: Scroll down to "Section: ROUTERSTART" and add (copy & paste) the following configuration block into the associated text box:

smarthost_dkim:
  driver = manualroute
  domains = !"+local_domains +smart_hosts"
  condition = "${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}{$value}}}{}{false}{true}}"
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 64.94.110.0/24
  headers_add = "${perl{mailtrapheaders}}"
  require_files = "+/var/cpanel/domain_keys/private/${sender_address_domain}"
  transport = remote_smtp_smart_dkim
  route_list = !+local_domains "${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}}"

smarthost_regular:
  driver = manualroute
  domains = !"+local_domains +smart_hosts"
  condition = "${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}{$value}}}{}{false}{true}}"
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 64.94.110.0/24
  headers_add = "${perl{mailtrapheaders}}"
  transport = remote_smtp_smart_regular
  route_list = !+local_domains "${lookup{$sender_address_domain}partial-lsearch{/etc/staticroutes}}"
		

Configure cPanel/WHM Smarthost for specific domains - ROUTERSTART

 

Step 4 : Scroll down to "Section: TRANSPORTSTART" and add (copy & paste) the following configuration block into the associated text box:

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/${dkim_domain}"
dkim_canon = relaxed

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}}
		

Configure cPanel/WHM Smarthost for specific domains - TRANSPORTSTART

 

Step 5: Create the following files on the server if they do not already exist:

/etc/staticroutes
/etc/smarthosts

Add entries for the domains you wish to have email routed to the Smarthost to both the /etc/staticroutes and /etc/smarthosts files in the following format:

domain.com: <IP address or hostname of your Smarthost> (including alternative port number if appliable)

Examples:

domain.com 216.55.xxx.xxx
domain.com smarthost.yourdomain.com
domain.com smarthost.yourdomain.com:587

Partial matching for sub domains for instance should also be possible using this type of format:

*.domain.com 216.55.xxx.xxx
*.sub.domain.com smarthost.yourdomain.com:
<port number if applicable>

Step 6: To activate the configuration rebuild the Exim conf and restart the Exim service:

/scripts/buildeximconf
service exim restart

Step 7: Check the Exim logs (usually /var/log/exim_mainlog) and the Mail Log Viewer on the outbound Smarthost to make sure that email is being routed properly.

*** Note: You can add or remove (or comment / uncomment) entries relating to Smarthost email routing for domains in the /etc/staticroutes and /etc/smarthosts files at any time. After making modifications to the Smarthost configuration there should be no need to update the configuration with the /scripts/buildeximconf or service exim restart commands however in the event that the configuration does not appear to update immediately then it may be necessary to issue these commands.

 

Product, sales or technical support related questions?  Contact Us