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] sendgrid_login: 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] send_via_sendgrid: driver = manualroute domains = ! +local_domains transport = sendgrid_smtp route_list = "* smtp.sendgrid.net::587 byname" host_find_failed = defer no_more
The last edit will be to the @[email protected] section:
@[email protected] sendgrid_smtp: driver = smtp hosts = smtp.sendgrid.net hosts_require_auth = smtp.sendgrid.net hosts_require_tls = smtp.sendgrid.net
Next we save the file and apply the changes:
/scripts/buildeximconf 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 H=smtp.sendgrid.net [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.