Implementing SendGrid with Exim on cPanel

05 Mar 2018 0 11  0
Implementing SendGrid with Exim on cPanel
Implementing SendGrid with Exim on cPanel


Causing your cPanel to send from a third-party mail server is pretty simple to do. If you know the basics of how cPanel builds its Exim configs. You won’t have to modify your exim.conf file directly, your modifications are going to be deleted any time a cPanel update runs or somebody makes a change in the Exim Configuration Editor in WHM. Here is a simple guide on setting up a custom mail router using a provider such as SendGrid. This will in turn route every outbound email through the external mail service.

The instructions you see below will show you how to do this with a command line. If you’d like WHM instead, just go to WHM -> Exim Configuration Manager -> Advanced Editor, then change the sections indicated.

Begin by opening up your /etc/exim.conf.local file in an editor, then search for the @[email protected] part and edit it to look like this:

@[email protected]
 driver = plaintext
 public_name = LOGIN
 client_send = : <user> : <password>

We will swap <user> with your SendGrid username and <password> with your SendGrid account password. If you currently have something in the AUTH section, just append the following block of text below it.

Search for the @[email protected] section, then edit it to look like this:

@[email protected]
 driver = manualroute
 domains = ! +local_domains
 transport = sendgrid_smtp
 route_list = "* byname"
 host_find_failed = defer

The last edit will be to the @[email protected] section:

@[email protected]
 driver = smtp
 hosts =
 hosts_require_auth =
 hosts_require_tls =

Next we save the file and apply the changes:


service exim restart

To see if things are working, send an email out from your server and look for it in /var/log/exim_mainlog. You will see something like the below in your log entry:

2013-10-08 19:37:29 1VTjeS-0000Ac-O3 -> [email protected] R=send_via_sendgrid T=sendgrid_smtp [x.x.x.x] X=TLSv1:DHE-RSA-AES256-SHA:256

In case you have SPF records. You will have to append the hostname of the SMTP server to the record itself to grant the third party mail server to send email on behalf of your domain. Sendgrid will provide the hostname you’ll need to use.


Add a comment

Leave a Reply