How to Configure the Exim Outgoing IP Address


Last modified: January 12, 2022

Overview

By default, Exim sends mail from the server’s primary IPv4 address. To decrease the chance that spam filters mark your mail as spam, verify that the reverse DNS (rDNS) entry of Exim’s outgoing IP address matches the DNS response of your server’s hostname.

Note:

The steps in this document require root-level privileges on the server.

Modify Exim preferences for outgoing mail

cPanel & WHM offers two ways by which to modify Exim’s default preferences for outgoing mail’s IP address:

Enable automatic configuration of the server IPv4 address for outgoing mail

To automatically configure Exim to send mail from each domain’s dedicated IPv4 address, perform the following steps:

  1. Modify the rDNS for each IPv4 address to point to the desired domain.

    Important:

  2. Enable the Send mail from account’s dedicated IP address setting in WHM’s Exim Configuration Manager interface (WHM » Home » Service Configuration » Exim Configuration Manager).

    Warning:

    If you select this setting, cPanel & WHM uses the /usr/local/cpanel/scripts/updateuserdomains script to automatically configure Exim, and overrides any manual changes in the following files:

    • /etc/mailhelo
    • /etc/mailips

Manually configure Exim outgoing IP addresses

Important:
  • We do not recommend that you modify your Exim files.
  • To modify your Exim configuration files, you must possess root-level privileges.

To use a custom Exim configuration, you must enable the following settings in the Basic Editor section of WHM’s Exim Configuration Manager interface (WHM » Home » Service Configuration » Exim Configuration Manager):

  • Reference /etc/mailhelo for outgoing SMTP HELO
  • Reference /etc/mailips for outgoing SMTP connections
Important:
  • If you disable the Reference /etc/mailhelo for outgoing SMTP HELO setting, the system will overwrite any changes that you make to the /etc/mailhelo file.
  • If you disable the Reference /etc/mailips for outgoing SMTP connections setting, the system will overwrite any changes that you make to the /etc/mailips file.

If you change the outgoing IP address to a non-cPanel main IP address, the cPanel user must update that email address’ SPF record. They can configure the SPF record in cPanel’s Email Deliverability interface (cPanel » Home » Email » Email Deliverability).

The mailhelo file

The /etc/mailhelo file contains Exim’s configuration for the HELO command, which initiates dialog between a mail server and a client. This file governs which domain sends the HELO command.

Use your preferred text editor to create an /etc/mailhelo file that resembles the following example:

1
2
3
4
5
example.com: example.com
sub.example.com: example.com
example.net: example.net
addon.example.net: example.net
*: hostname.example.com

The mailips file

The /etc/mailips file controls the IP address from which each domain sends mail.

Use your preferred text editor to create an /etc/mailips file that resembles one of the following examples:

IPv4

1
2
3
4
5
example.com: 192.0.2.0
sub.example.com: 192.0.2.1
example.net: 192.0.2.2
addon.example.net: 192.0.2.3
*: 192.0.2.4
Note:
  • In the example above, the system uses the asterisk (*) entry to direct outbound mail for domains without entries within this file. In this case, this is your server’s main shared IPv4 address. You can set this value to another IP address if you ensure that the asterisk entry in the /etc/mailhelo file uses the appropriate domain name.
  • Only use valid, publicly-accessible IP addresses.
  • Do not separate multiple IP addresses with commas. Instead, use semicolons.

IPv4 with NAT

NAT (Network Address Translation) transforms your private IPv4 address into a public IPv4 address. This process helps to preserve the limited number of IPv4 IP addresses available.

Exim sends mail from the server’s primary IPv4 address. You must use your private IP address, and not your public NAT IP address, when configuring the Exim service.

1
2
3
4
5
example.com: 192.168.0.2
sub.example.com: 192.168.0.2
example.net: 192.168.0.3
addon.example.net: 192.168.0.3
*: 192.168.0.1
Note:
  • Only use private IPv4 addresses on a NAT system.
  • Do not separate multiple IPv4 addresses with commas. Instead, use semicolons.

IPv6

IPv6 does not utilize NAT technology due to the large number of IPv6 addresses available. For more information about IPv6, read our Guide to IPv6 documentation.

1
2
3
4
5
example.com: 2001:db8:3c4d:15::7334
sub.example.com: 2001:db8:3c4d:15::7334
example.net: 2001:db8:3c4d:15::7334
addon.example.net: 2001:db8:3c4d:15::7334
*: 2001:db8:3c4d:15::7334
Note:
  • Only use valid, publicly-accessible IPv6 addresses. In the example above, the system uses two colons (::) to indicate a collapsed section.
  • Do not separate multiple IPv6 addresses with commas. Instead, use semicolons.

Additional Documentation