How to configure Exim to use SendGrid to send mail

I continue my series of articles about email services until the inspiration from the recently solved problems wears off.

I have already described how to configure PostFix to send mail via MailGun.

This article will discuss how to configure Exim to use the SendGrid mail delivery service.

The description of setting up different mail services on different mail daemons coincides very well.

I have a server with WHM + Exim panel. I signed up for a free account with SendGrid.

First, in the WHM panel, find Exim Configuration Manager Screenshot from 2016-03-01 13:59:38

Go to the Advanced Editor tab and look for the Section: AUTH section. In the text field you need to insert information for authorization in sendgrid:

   driver = plaintext
   public_name = LOGIN
   client_send = : [email protected] : %password%

Next we look for the section Section: ROUTERSTART. We insert the following into it:

   domains = ! +local_domains
   transport = sendgrid_smtp
   route_list = "* byname"
   host_find_failed = defer

All that remains is to specify the transport. To do this, find Section: TRANSPORTSTART and enter the following in the text field:

   driver = smtp
   hosts =
   hosts_require_auth =
   hosts_require_tls =

If you want to use DKIM then TRANSPORTSTART is exactly the place to add the configuration:

DKIM_CANON = relaxed
DKIM_FILE = /etc/ssl/private/