Control Panels

How to Send cPanel Mail Through a Smart Host (Exim Smarthost Setup)

Need to relay outgoing emails through another mail server? Learn how to set up a Smart Host in Exim to route emails efficiently.

Short answer: In WHM, open Service Configuration > Exim Configuration Manager > Basic Editor, go to the Mail tab, and enter a route list in Smarthost support, for example * smtp.relay.example.com::587. If the relay needs a user name and password, turn on Smarthost requires SMTP authentication and add the credentials as cPanel describes. Save, then send a test message and check /var/log/exim_mainlog for the relay host.

What a smart host is

A smart host is another mail server that accepts your outgoing mail and delivers it for you. Instead of connecting to each recipient’s mail server, Exim hands every outgoing message to the smart host. Common reasons to use one:

  • Delivery: a relay service with a good reputation, such as an email delivery provider or Google Workspace’s SMTP relay.
  • Outgoing filtering: a filtering service scans outgoing mail for spam before it leaves.
  • Blocked port 25: some networks block direct outgoing connections on port 25.
  • One sending address: all servers send from a central relay, which is easier to manage.

Incoming mail is not affected. Your MX records and mailboxes stay the same.

Before you start

  • ✓ The relay’s host name and port (usually 587 with TLS, or 25 for IP-authorised relays).
  • ✓ How the relay authenticates you: by your server IP address, or with a user name and password.
  • ✓ The relay’s SPF value, to add to your domains’ SPF records.
  • ✓ A backup of the current Exim configuration. Exim Configuration Manager can make one for you.

Step 1: set the smart host in the Basic Editor

  1. In WHM, open Service Configuration > Exim Configuration Manager.
  2. Open the Basic Editor and the Mail tab.
  3. Find Smarthost support and enter the route list (see below).
  4. If the relay needs a login, turn on Smarthost requires SMTP authentication and follow the prompts.
  5. Click Save. WHM rebuilds the Exim configuration and restarts Exim.

A route list has a domain pattern, then the relay host. The * means all remote domains. A port can be added after two colons:

# All outgoing mail through one relay on port 587
* smtp.relay.example.com::587

# Two relays, tried in order
* "smtp1.relay.example.com::587 : smtp2.relay.example.com::587"

Check your relay’s documentation for the exact host and port.

Step 2: authentication

Relays that authorise your server by IP address need no password: ask the relay to allow your server’s IP. Relays that need a login use the authentication setting above, with the credentials added as cPanel’s documentation describes for your version. If several domains on the server need different logins, cPanel documents a way to add per-domain authenticators in the Advanced Editor.

Do not edit /etc/exim.conf directly. cPanel rebuilds it, so changes there are lost. Older guides that add routers to /etc/exim.conf.local by hand should be replaced with the Basic Editor settings, which cPanel added for this purpose.

Step 3: update SPF

Mail now leaves through the relay, so each domain’s SPF record must allow it. Add the relay’s include, keeping a single SPF record per domain, for example:

v=spf1 +a +mx +ip4:203.0.113.10 include:spf.relay.example.com ~all

WHM’s Email Deliverability page shows any domains whose records need fixing. See our Email Deliverability guide.

Step 4: test and check the logs

# Send a test from the server
echo "smarthost test" | mail -s "Smarthost test" you@example.org

# Watch the delivery
tail -f /var/log/exim_mainlog

A successful delivery shows T= with the smart host transport and H=smtp.relay.example.com. Open the received message and check the headers: SPF and DKIM should pass.

Keep DKIM signing

cPanel signs outgoing mail with each domain’s DKIM key. The Basic Editor smarthost option keeps cPanel’s normal signing. If you build a custom router or transport in the Advanced Editor instead, check that messages still carry a valid DKIM signature, because a custom transport may not sign them.

Troubleshooting

Problem Likely cause Fix
Mail stays in the queue The relay refuses the connection or the login Check the error in exim_mainlog, the port, and the credentials or IP authorisation.
535 Authentication failed Wrong user name or password Correct the credentials and save the configuration again.
Messages land in spam SPF does not include the relay, or DKIM fails Fix the SPF record and check the DKIM signature in the headers.
Local mail goes to the relay The route list matches local domains Use the Basic Editor option, which only routes remote domains.

Need help with this?

Mail delivery problems from your server? Our team can set up a relay and fix SPF, DKIM and DMARC for you.

See server management plansContact @CustomerPanel

Frequently asked questions

How do I set up a smart host in cPanel?

In WHM, open Exim Configuration Manager > Basic Editor > Mail and enter a route list in Smarthost support, then save.

Can the smart host require a password?

Yes. Turn on Smarthost requires SMTP authentication in the Basic Editor and add the credentials as cPanel documents.

Do I need to change my MX records?

No. A smart host only handles outgoing mail.

Will my SPF record need changing?

Yes. Add the relay’s include or IP addresses to each domain’s SPF record.

Should I edit exim.conf directly?

No. cPanel rebuilds it. Use Exim Configuration Manager.


Sources