Configuring your Cpanel/WHM managed domain to use SendGrid’s SMTP mail servers is quite easy.You will need root access to do this.

  1. Login to your VPS or server using your root login credentials
  2. Go to Service Configuration -> Exim Configuration Manger
  3. Then click the “Advanced Editor” tab

  4. Find a section called Section: AUTH a(You may want to use the “find” function of your browser to find it since this configuration file is rather large). The section will be empty. Paste the following into the text box, replacing “YourSendGridUsername : YourSendGridPassword” with your real sendgrid username and password
    sendgrid_login:
    driver = plaintext
    public_name = LOGIN
    client_send = : YourSendGridUsername : YourSendGridPassword

  5. Find the section called Section: PREROUTERS paste the following in the textbox, replacing “*@Yourdomainhere” with your domain. If you want to cover the entire server, then put in an asterick in place of “Yourdomainhere”, for example “*@*” :
    send_via_sendgrid:
    driver = manualroute
    domains = ! +local_domains
    senders = *@<YourDomainHere>
    transport = sendgrid_smtp
    route_list = "* smtp.sendgrid.net::587 byname"
    host_find_failed = defer

  6. Find the section called Section: TRANSPORTSTART and paste the following in the textbox:
    sendgrid_smtp:
    driver = smtp
    hosts = smtp.sendgrid.net
    hosts_require_auth = smtp.sendgrid.net
    hosts_require_tls = smtp.sendgrid.net

Save the file, and exim will restart. That’s all there is to it, you should now be able to send emails with no problem and it will all automatically route through your sendgrid account. You can cehck by logging into shell and running tail -f /var/log/exim_mainlog. You will see the emails going through your sendgrid. Thank you!