Skip to main content
This guide covers advanced Exim configuration for servers running Exim outside cPanel, or for administrators who manage the Exim configuration files directly. It includes the full router and transport setup for routing mail through MailChannels, file-based domain exclusions, per-user rate limiting, the X-AuthUser header for sender identification, and queue management settings.
Always back up your Exim configuration files before making changes. Errors in the Exim configuration prevent the mail service from starting.

Prerequisites

  • Root-level access to your Linux server
  • Your MailChannels SMTP username and password
  • Exim 4.x or newer installed and running
Exim uses either a monolithic configuration file (/etc/exim.conf) or a split configuration under /etc/exim4/conf.d/ (common on Debian/Ubuntu). The snippets below apply to either format — place each block in the corresponding section of your configuration.

Core configuration

Authentication

Add the following block to the begin authenticators section of your Exim configuration. This tells Exim how to log in to smtp.mailchannels.net using your credentials.
Authenticators section
Replace MailChannelsUsername and MailChannelsPassword with your actual MailChannels SMTP credentials. For systems that store credentials in a separate file (such as /etc/exim4/passwd.client on Debian-based systems), add the following line to that file and restrict its permissions.
/etc/exim4/passwd.client

Router

Add the following block to the routers section. Place it early in the router list so it intercepts outgoing mail before other rules. It routes all non-local mail to smtp.mailchannels.net.
Routers section
If you are on a cPanel server and applying these settings manually, place the router block in Section: POSTMAILCOUNT in WHM’s Exim Advanced Editor. This ensures cPanel’s hourly email limits are enforced before mail is handed off to MailChannels.

Transport

Add the following block to the transports section. It defines how Exim connects to MailChannels, including TLS requirements, authentication, the X-AuthUser sender identification header, and DKIM signing.
Transports section
The X-AuthUser header value is derived from $authenticated_id, which Exim populates with the email address or username of the authenticated sender. MailChannels uses this value to attribute messages to individual users for reputation and abuse tracking. The third field of the senderID (sid=) in the MailChannels console reflects this value.
Adjust the dkim_private_key path to match where your DKIM private keys are stored. Systems managed by cPanel typically keep keys under /var/cpanel/domain_keys/private/. OpenDKIM installations often use /etc/dkim/keys/.

Reload Exim

After editing the configuration, restart Exim for changes to take effect.

Exclude domains from MailChannels routing

You can exclude specific sender or recipient domains so their mail bypasses MailChannels and is delivered directly. The method depends on your Exim version.

Exclude recipient domains (file-based)

1

Create the exclusion file

Create /etc/excludereceiverdomains and list each domain to exclude, one per line with a trailing colon.
/etc/excludereceiverdomains
2

Declare the domain list

Add the following line to Section: CONFIG (or the main section of your exim.conf):
Section: CONFIG
3

Reference the list in the router

Update the domains line in your send_via_mailchannels router to reference the exclusion list:
Updated router — recipient domain exclusion
4

Restart Exim

Exclude sender domains (file-based)

1

Create the exclusion file

Create /etc/excludesenderdomains and list each domain to exclude, one per line without a trailing colon.
/etc/excludesenderdomains
2

Declare the domain list

Add the following line to Section: CONFIG (or the main section of your exim.conf):
Section: CONFIG
3

Reference the list in the router

Add a senders line to your send_via_mailchannels router:
Updated router — sender domain exclusion
4

Restart Exim

On Exim 4.89, the file-based lsearch method for sender domain exclusion may not work as expected. Use the inline syntax instead:
Exim 4.89 inline sender exclusion

Exclude mailer-daemon bounces

To prevent mailer-daemon bounce messages from being relayed through MailChannels, add the following senders condition to your router:
Exclude mailer-daemon bounces

Inline domain-specific routing (without files)

For a small number of domains, you can specify inclusions and exclusions directly in the router without creating external files.
Route only specific sender domains
Exclude specific sender domains inline
Exclude specific recipient domains inline

Rate-limit individual users

Limiting how many messages an authenticated user can send per hour is one of the most effective ways to contain the damage when an account is compromised. Add the following condition to your Exim ACL (access control list) for SMTP DATA or RCPT:
Rate limit per authenticated sender
This limits each authenticated user to 50 messages per hour. Adjust the count to match your policy. Exim will reject messages that exceed the limit with a temporary error, prompting the sending client to retry later.
For a more comprehensive approach to blocking compromised accounts in Exim — including detecting dictionary attacks and cracking attempts — see the community-maintained BlockCracking guide on the Exim wiki.

Queue management

These settings control how Exim handles the mail queue and retries. They typically belong in the main section and the begin retry section of your configuration.

Retry intervals

Add or update the following in the begin retry section. These values are recommended by MailChannels to balance timely retries with queue health.
Retry section
If you see retry time not reached for any host errors caused by Exim caching a stale MailChannels IP, run the following commands to clear the retry and wait databases immediately:
To prevent this from recurring, add a weekly cron job:

Queue runner frequency

For systemd-based systems, create a service override to run the queue every 60 seconds:
Add the following to the override file:
systemd service override
For older init.d systems, edit /etc/default/exim (Debian/Ubuntu) or /etc/sysconfig/exim (CentOS/RHEL/CloudLinux):

Queue runner limits and frozen messages

Add or modify these in the main section of exim.conf:
Main section — queue settings

Verify the setup

After restarting Exim, confirm that mail is routing correctly.
  1. Monitor the mail log. Tail the main log and look for entries showing R=send_via_mailchannels and T=mailchannels_smtp with a destination of smtp.mailchannels.net.
  2. Send test emails. Send from several local accounts to external recipients and verify successful delivery.
  3. Check received headers. Examine the headers of delivered messages to confirm smtp.mailchannels.net appears in the Received: chain and that the X-AuthUser header is present with the correct value.
  4. Review the MailChannels console. Log in to your MailChannels Host Console to confirm that messages from your server appear in Outbound > Activity > LogSearch and that sender attribution is correct.