Setting up a custom mail router with a provider like SendGrid, which in turn will route all outbound email through the external mail service.
First, open up your /etc/exim.conf.local file in an editor and look for the @AUTH@ section. Modify it to look like this:
@AUTH@
sendgrid_login:
driver = plaintext
public_name = LOGIN
client_send = : <user> : <password> Replace <user> with your SendGrid username and <password> with your SendGrid account password. If you already have something in the AUTH section, simply add this block of text below it.
Now look for the @PREROUTERS@ section, and modify it to look like this:
@PREROUTERS@
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 modification should be to the @TRANSPORTSTART@ section:
@TRANSPORTSTART@
sendgrid_smtp:
driver = smtp
hosts = smtp.sendgrid.net
hosts_require_auth = smtp.sendgrid.net
hosts_require_tls = smtp.sendgrid.net Now save the file, and apply the changes:
/scripts/buildeximconf
service exim restart
To test whether things are working, send an email out from your server, and look for it in /var/log/exim_mainlog. You should see something like this in your log entry:
2013-10-08 19:37:29 1VTjeS-0000Ac-O3 -> my@email R=send_via_sendgrid T=sendgrid_smtp H=smtp.sendgrid.net [x.x.x.x] X=TLSv1:DHE-RSA-AES256-SHA:256 If you have SPF records, you’ll need to add the hostname of the SMTP server to the record itself to allow the third-party mail server to send email on behalf of your domain. Sendgrid will provide the hostname you should use.
