Configuring a domain in cPanel/WHM to use SendGrid’s SMTP service enhances email deliverability and ensures reliable message delivery. Here’s a straightforward guide to set this up:
- Login to your WHM account using the root credentials
- Click on Service Configuration -> Exim Configuration Manger
- Click on the Advanced Editor tab as shown in the screenshot below
- Find the section called Section: AUTH and paste the following into the text box, substituting in your SendGrid username and password:
sendgrid_login:
See my screenshot below:
driver = plaintext
public_name = LOGIN
client_send = : <YourSendGridUsername> : <YourSendGridPassword> - Find the section called Section: PREROUTERS paste the following in the textbox, substituting in your Domain name in the senders line:
send_via_sendgrid:
See my screenshot below:
driver = manualroute
domains = ! +local_domains
senders = *@<YourDomainHere>
transport = sendgrid_smtp
route_list = "* smtp.sendgrid.net::587 byname"
host_find_failed = defer - Find the section called Section: TRANSPORTSTART and paste the following in the textbox:
sendgrid_smtp:
See my screenshot below:
driver = smtp
hosts = smtp.sendgrid.net
hosts_require_auth = smtp.sendgrid.net
hosts_require_tls = smtp.sendgrid.net
Table of Contents
Important Considerations
- API Key: Ensure you’ve generated a SendGrid API key with at least ‘Mail’ permissions. Replace
YOUR_SENDGRID_API_KEY
in the configuration with this key. - Domain-Specific Configuration: If you want only a specific domain to use SendGrid while others continue using the default SMTP, adjust the
senders
parameter in the Section: POSTMAILCOUNT configuration:iniCopyEditsenders = *@yourdomain.com
Replaceyourdomain.com
with the desired domain. - Testing: After configuration, send a test email to confirm that emails are routing through SendGrid. Monitor
/var/log/exim_mainlog
for any errors:bashCopyEdittail -f /var/log/exim_mainlog
By following these steps, your cPanel/WHM server will route outgoing emails through SendGrid, enhancing deliverability and providing robust email management features.
FAQs
Why should I use SendGrid with cPanel/WHM?
A1: Integrating SendGrid improves email deliverability, offers advanced analytics, and reduces the chances of your emails being marked as spam.
Can I configure multiple domains to use SendGrid?
Yes, by specifying multiple domains in the senders
parameter or using wildcards, you can route emails from multiple domains through SendGrid.
What if I encounter errors after configuration?
Check the Exim main log at /var/log/exim_mainlog
for error messages. Ensure that your API key is correct and that your server can connect to smtp.sendgrid.net
on port 587.
By setting up SendGrid as your SMTP relay in cPanel/WHM, you can achieve more reliable and efficient email delivery for your domains.