cPanelResources

Tutorial How to use SendGrid as a Smarthost

*** This guide is a task intended for system administrators. cPanel's Technical Analysts cannot provide assistance in configuring a server's Smarthost setup. ***

Overview
Many providers now block outbound connections on port 25, which means that a cPanel system would need to configure a Smarthost to allow for outbound emails to function. This resource will go through how to setup a Smarthost using a common 3rd party mail provider, SendGrid.

Note: Click here to read the corresponding resource for setting up a smarthost with MailGun.

It is important to note that configuring a Smarthost will cause all outbound emails to go through the configured provider. The scope of this resource does not cover only having certain domains go through a Smarthost. That would be something that must be configured by the system administrator of the server.

SENDGRID
SendGrid has a free plan which allows for 40,000 emails to be sent through their system within the account's first 30 days. After the 30 days have concluded, the free plan would only allow 100 emails per day.

1. The first step will be to sign up here if you have not already done so.

2. The next step will be to log in to WHM as the root user. Once logged in, navigate to WHM > Service Configuration > Exim Configuration Manager > Advanced Editor. On this page, search for "Section: AUTH". In the text box, input the following:

Code:
sendgrid_login:
  driver = plaintext
  public_name = LOGIN
  client_send = : YOUR-SENDGRID-USERNAME:YOUR-SENDGRID-PASSWORD
You must replace "YOUR-SENDGRID-USERNAME" and "YOUR-SENDGRID-PASSWORD" with your actual SendGrid username and password. EX:

Code:
client_send = : myusername:mypassword
Here's an image showing an example of how this should look:

sendgrid-auth.png

3. Now go to the "Section: PREROUTERS" section and input the following in the text box:

Code:
send_via_sendgrid:
  driver = manualroute
  domains = ! +local_domains
  transport = sendgrid_smtp
  route_list = "* smtp.sendgrid.net::587 byname"
  host_find_failed = defer
  no_more
Here's an image showing an example of how this should look:

sendgrid-prerouters.png

4. The last configuration that will need to be set will be for "Section: TRANSPORTSTART". Add the following into its text box:

Code:
sendgrid_smtp:
  driver = smtp
  hosts = smtp.sendgrid.net
  hosts_require_auth = <; $host_address
  hosts_require_tls = <; $host_address
Here's an image showing an example of how this should look:

sendgrid-transportstart.png

5. Navigate to the bottom of the page and click "Save". This will save the changes that have been made, and automatically restart the Exim service.

6. Now try sending a test email, preferably from one of the Webmail applications, and verify that it was received. If the email gets queued on the server, then the /var/log/exim_mainlog file will need to be examined to determine the cause of the issue.

Questions/Feedback
Feel free to click on the Discussion tab to let us know if you have any questions or feedback about the information in this tutorial.
Author
cPanelResources
Views
311
First release
Last update