When it comes to troubleshooting WordPress not sending emails, this can sometimes be a little tricky. Why? Because many managed WordPress hosts do not provide traditional email hosting.
At Kinsta we route transactional emails via MailChannels for you, but SendGrid is another popular transactional email service provider. A few examples of transactional emails include new user registration emails, password reset emails, WooCommerce order notifications, etc. Basically, the essential emails that are required for site functionality or anything that isn’t marketing related. This means you can typically get up and going without having to worry about email.
However, our relay service via MailChannels isn’t meant for sending bulk emails. We also have limits on how many transactional emails you can send per day to prevent spam/abuse.
Therefore, if you need complete control over your DNS records (DKIM) or are having trouble with emails going out, it can be beneficial to configure your own WordPress with a third-party SMTP provider (transactional email service).
Today we’ll show you how to configure SendGrid in WordPress to send emails.
What is SendGrid?
SendGrid (now owned by Twilio) is used by some of the biggest names in the industry such as Uber, Spotify, Yelp, Airbnb, and even Kinsta. It originally started out as a transactional email SMTP and API serviced designed for developers. However, they now also offer email marketing features as well. So you can use them for one or the other or both. Today we’ll be focusing on the transactional side of things, as that is what most of you are probably trying to get up and running.
SendGrid has a 30-day free trial in which you can send up to 40,000 emails. After that, you can continue the free trial forever for free and send up to 100 emails/day.
If you need more emails than that, their Essentials plan starts at $14.95/month and you can send up to 40,000 emails per month. The cost per extra email is $0.001. But you can also upgrade to a higher plan to save more money.
A few additional benefits include:
- Ability to use Web API or SMTP to deliver emails. The Web API is faster and includes functionality for managing user unsubscribes, managing IPs, templating emails, and more.
- Improve deliverability rates to hit users inboxes with domain and link customization, whether sending from shared IP pools or a dedicated IP.
- Eliminate domain spoofing and phishing emails with our custom SPF and DKIM record creation.
- Benefit from continuous mail flow through our secure, distributed, and redundant data centers.
- Live and searchable logs.
Create a SendGrid Account and API Key
The first thing you will need to do is create a SendGrid account and generate your API key. Follow the steps below.
First, signup for a free trial at SendGrid.com. Then verify your account by clicking on the confirmation email you receive.
Once you are in, we highly recommend setting up two-factor authentication. Email delivery and routing are very important, and the last thing you want is for someone to hack your account. This adds an extra layer of protection to your account. You can do this under “Settings” → “Two-Factor Authentication.”
They give you two options: The Authy App (recommended) or text message (SMS).
Next, you will need to generate your SendGrid API key. Click into “Settings” → “API Keys.” Then click on “Create API Key.”
Give your API a name you can recognize. This can be anything. Select “Full Access” and click on “Create & View.”
You will want to copy your API key and save it somewhere safe as they won’t show it to you again. You will need this to configure the plugins below.
How to Configure SendGrid in WordPress with Post SMTP Plugin
We recommend configuring SendGrid with the popular free Post SMTP plugin. Perhaps you are already using this plugin with your current set up, so switching it over to SendGrid should be easy.
The Post SMTP plugin is regularly updated and supports sending via SendGrid’s SMTP relay as well as SendGrid’s Web API. It currently has 100,000+ active installs with an impressive 5 out of 5-star rating.
You can download it from the WordPress repository or by searching for it within your WordPress dashboard under “Plugins” → “Add New.”
Here are a couple of reasons why you might want to use the Web API method vs SMTP:
- SMTP connections have multiple points of failure.
- The Web API method is typically faster with less latency than SMTP.
- The Web API adds an additional layer of security with API keys, vs the standard credential method with SMTP.
- Sometimes WordPress hosts block outbound connections with SMTP on ports 25, 465, and 587. Or they might not even support SMTP at all. With the Web API method, you don’t have to worry about this. Note: If you’re a Kinsta client, only port 25 is blocked.
- Replaces the default wp_mail function to send emails.
After you install the plugin, click on “Post SMTP” → “Start the Wizard.”
Enter in the email address and name that you would like to “send mail as.” This is what users will see when they get an email from your site. Then click “Next.”
We are going to use SendGrid’s API, not SMTP. But having the SMTP server will be a fallback in the future in case there is anything wrong with the API. So enter in SendGrid’s SMTP server address which is:
smtp.sendgrid.net. Then click “Next.”
Select “SendGrid API” and click “Next.”
Now back in the Post SMTP Setup, paste in your SendGrid API key which you generated earlier and click “Next.”
You can then choose how you want to be notified when an email is failed to be delivered. Email is the default and easiest option. Post SMTP even has a Slack option. Then click “Next.”
You can then send a test email to ensure everything is working properly. Under the Actions menu click on “Send a Test Email.”
Type the recipient email address you want to send a test to and click “Next.” If everything is OK you will see a “Success” message.
And that’s it! All emails from your WordPress site will now go out via SendGrid’s mail servers. Make sure to check your inbox and your spam folder to ensure the test email went through. You can also check the SendGrid activity feed.
You should then skip down to the section below to configure your SendGrid domain authentication.
Configure SendGrid Domain Authentication
Configuring your SendGrid domain authentication will improve deliverability by proving to inbox providers that you own the domain you’re sending from. Without this, your emails might end up in the spam folder.
In the SendGrid dashboard, click into “Settings” → “Sender Authentication.” Under the Domain Authentication section, click on “Get Started.”
Pick the DNS host you are using. If you are using Kinsta DNS, you can choose Amazon Route 53. If you are using Cloudflare, then you can select Cloudflare. Then click “Next.”
Enter in the domain you are sending from. You can then choose which type of security you prefer. The default and recommended option is “Use automated security.” When Enabled, SendGrid will automatically rotate your DKIM keys so that they are impossible to break. Then click “Next.”
You will then need to add DNS records so that your email points to SendGrid. You can do this at your domain registrar or third-party DNS provider. They require three CNAME records. If you need help with this, you can always ask for assistance from your provider. If you are a Kinsta client and using our premium DNS, you can set these up within the MyKinsta dashboard. Or reach out to our support team for help.
Once you’ve added them, check the “I’ve added these records” box and click on “Verify.” Note: After adding your DNS records it might take a while to propagate. Most will only take a couple of minutes, but it could take up to 24 hours.
You should then see a “It worked!” message when the domain verification is complete.
You should be all set up now for sending emails! Remember, the plugins above replace the default wp_mail function. This means all emails going out from your site will now route through SendGrid.
Looking for good email hosting? We highly recommend G Suite.
If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans