How to Set Up the SendGrid Mailer in WP Mail SMTP

Would you like a reliable, secure email delivery solution that works with a variety of email addresses? In this tutorial, we’ll walk you through how to set up WordPress email notifications with SendGrid using WP Mail SMTP.


What is SendGrid?

SendGrid is a popular method of improving email delivery. They do this through an API, which provides a more secure method than traditional SMTP. Further, they offer both free and paid options depending on the number of emails you need to send each month.

SendGrid’s free plan allows your site to send up to 40,000 emails for your first 30 days, then 100 emails per day after that. For most small businesses and personal websites, that’s plenty. If you need to send more emails, though, you will likely need one of their paid plans.

In order to use SendGrid effectively, you will need to have an email address associated with a domain that you own (emails that are @gmail.com, @yahoo.com, etc are not recommended for use with this mailer).

1. Configuring Your SendGrid Account

In order to connect your website with SendGrid, you’ll first need to set up a SendGrid account and getting the API key. This key is a unique identifier for authentication that will allow your website to communicate with your account in SendGrid.

Creating a SendGrid Account

If you haven’t already, you’ll need to sign up for a SendGrid account by visiting their Pricing page. From here, you can choose the account type that fits your site’s needs.

For our example, we’ll be signing up for their free plan (limited to 100 emails per day). However, the setup will be the same no matter which plan you choose.

SendGrid pricing page

Next, SendGrid will ask you to fill out a couple forms to create your account and set up a profile.

Create an account with SendGrid

Generating an API Key

After you’ve created an account, click the Start button next to Integrate using our Web API or SMTP relay.

Start SMTP setup in SendGrid

For the next step, you’ll be asked to choose a setup method. Go ahead and click the Choose button under the SMTP Relay option.

Choose SMTP Relay for SendGrid setup

Next, you’ll need to enter an API key name and then click Create Key.

Create API key for SendGrid

This will generate an API key for you. Be sure to leave this page open, as we’ll need this API key a little later.

API key for SendGrid account

2. Setting Up WP Mail SMTP

Now that your SendGrid account is prepped, we can switch over to setting up WP Mail SMTP.

Before we get started on this section, be sure to install and activate the WP Mail SMTP plugin.

Once WP Mail SMTP is installed, you’ll need to click on WP Mail SMTP in the left WordPress menu to open the plugin settings page. We’ll discuss each of these settings in detail below.

From Email

This is the email address that all of your site’s emails will be sent from.

You can also choose to check the box labeled Force From Email. If you’d like the From Email to be the same site-wide, this option will save you the trouble of editing the email settings throughout your site (in all form emails, etc).

Adjust From Email in WP Mail SMTP settings

From Name

The From Name will, by default, be set to the site name. However, you can change this to any text you’d like.

You can also choose to Force From Name to apply this setting to emails site-wide.

Adjust From Name in WP Mail SMTP settings

Mailer

In the Mailer field, you’ll need to select the SendGrid option.

select sendgrid mailer option in wpmailsmtp

It’s also recommended to check the optional Return Path checkbox to Set the return-path to match the From Email. With this enabled, you should be emailed if any messages bounce as a result of issues with the recipient’s email.

Set return path to match From Email

The last step on this page is to scroll to the SendGrid section and enter the API Key. Go ahead and flip back to the tab or window where your SendGrid account is open to copy the key you generated earlier.

After copying the key, return to the WP Mail SMTP settings and paste it into the API Key field. Then, be sure to click the Save Settings button.

Paste in SendGrid API key and save settings

3. Verifying SendGrid Integration

Next up, you’ll need to verify the integration that you just created with SendGrid. To get this process started, you’ll need to send a test email from WP Mail SMTP.

Still in your WP Mail SMTP settings, click on the Email Test tab.

Open the Email Test tab in WP Mail SMTP

On this tab, you can enter any email address that you have access to. Then, click the Send Email button.

Once the email has processed, you should see a success message.

Notice showing the WP Mail SMTP test email sent successfully

Now that your test email has been sent successfully, you’ll need to go back to your SendGrid account’s API page. There, check the box labeled I’ve updated my settings and then click Next: Verify Integration.

Complete the Configure Your Application step in SendGrid

When the next page loads, click the Verify Integration button. This will send an email to SendGrid for verification.

Verify integration in SendGrid

Once SendGrid has detected that your test email has already been sent, they’ll let you know with a success message. This may take a few moments to complete.

Success message from SendGrid integration verification

At this point, it may look like your SendGrid setup is ready to go. However, for long-term, reliable email delivery we strongly recommend continuing to the next step.

4. Authenticating Your Domain in SendGrid

The best way to ensure that your emails continue to deliver successfully over time is to authenticate your domain.

Authentication proves that your emails come from a domain that you own. This, in turn, helps your domain’s reputation as a legitimate email source. As an added benefit, authentication will also remove the “via sendgrid.net” message that would otherwise get added to your emails.

Note: In order to move ahead with domain authentication, you’ll need access to your site’s DNS settings.

If you’re not sure where to find DNS settings, or feel unsure about making changes, please contact your site’s hosting provider before making adjustments. Or for more details on modifying a site’s DNS, you can check out WPBeginner’s tutorial on DNS settings.

To get started on authentication, in SendGrid’s left menu go to Settings » Sender Authentication (or simply follow this link).

Near the upper right of the page, click the Get Started button.

Click the Get Started button for Sender Authentication

On the first authentication setup page, you’ll need to answer 2 questions:

  1. Which Domain Name Server (DNS) host do you use? Select your DNS provider from the available list. If you don’t see a match, then choose Other Host (Not Listed).
  2. Would you also like to brand the links for this domain? We recommend selecting Yes. This will allow any links in the emails that are sent to use your own domain, rather than SendGrid’s. Branded links help to further ensure delivery by keeping all links tied to your own site.

When these questions are complete, click the Next button.

For the next step, you’ll need to enter your site’s domain (ie wpmailsmtp.com).

Enter your domain for SendGrid authentication

After entering the domain, click on Advanced Settings to open it. You’ll need make a couple of adjustments here:

  1. Uncheck the box labeled Use automated security.
  2. Check the box labeled Use custom return path.
  3. In the Return Path field, add a subdomain (see below for details).

Uncheck automated security option and check custom return path

What is a subdomain (Return Path)?

A subdomain replaces the “www” part of your website’s address. For example: subdomain.yourwebsite.com. Subdomains can be used to add separate sections or directories to your website (for example, a site’s blog might be at blog.example.com).

In this case, the subdomain will only be used by SendGrid to send emails and will not be visible on your site at all.

Unless you have a specific subdomain in mind, consider using sg — this is what we’ll use in our example here.

Note: The subdomain can be anything you’d like, however SendGrid recommends:
– Not using “mail”, as many hosting companies will already use this and it could cause conflicts.
– Not including any underscores (_) as this may not be compatible with some DNS providers

After clicking Next, the following page will display a list of DNS records that you’ll need to add for your site.

Note: If you’re not sure where to find your site’s DNS settings or feel unsure about making changes, please contact your site’s hosting provider before making adjustments.

Or for more details on modifying a site’s DNS, you can check out WPBeginner’s tutorial on DNS settings.

After you’ve opened up the DNS settings for your site, you should see an option to add a new record.

To make it possible for SendGrid to verify your domain, you’ll need to add three records to your site’s DNS. Be sure to copy them carefully, as you’ll need the exact values from your SendGrid account for the verification to work.

DNS records to add for SendGrid

Note: If your DNS is managed by GoDaddy, then you will slightly adjust the Hostname shown in SendGrid. When entering the Hostname into your GoDaddy DNS, you’ll need to remove your normal domain. For example, instead of entering sg.yourdomain.com for the first TXT record’s Hostname, you would only enter sg

In your site’s DNS settings you may also see a TTL (Time To Live) field for the record. If you’re provided with a way to change this, we recommend setting the TTL to one day (or 86400 seconds, depending on the units your DNS uses).

After adding all 3 DNS records, check the box labeled I have added these records. Then, click the Verify button. DNS changes can take up to 48 hours to be recognized, so you may need to check back on this later.

Verify that DNS records have been added

If the verification worked, you should see a success message.

DNS records are verified

4. Sending a Test Email

Once your domain is authenticated, it’s a good idea to send one more test email. Back in your WordPress site’s admin area, you’ll need to go to WP Mail SMTP » Settings » Email Test.

Open the Email Test tab in WP Mail SMTP

Go ahead and enter any email address that you have access to. Then, click the Send Email button.

Once again, you should see a success message.

Notice showing the WP Mail SMTP test email sent successfully

If you check the inbox for that email address, you should also soon receive the email for this test.

Successful test email from WP Mail SMTP

At this stage, it’s also important to check that your domain authentication worked. Each email provider will place this information in a different spot, but we’ll go ahead and share Gmail/G Suite as an example.

Within a Gmail or G Suite email, you’ll need to click the small arrow under the sender details. This should open more details about the email header. From here, check that the mailed-by value matches your subdomain (ie sg.yourdomain.com). Then, check that the signed-by value matches your regular site domain (ie yourdomain.com).

Check domain authentication details in email

Note: If these domains don’t match your subdomain/domain yet, then SendGrid may require a little more time to fully apply your setup. We recommending waiting at least an hour, then repeating this test process.

That’s it! You’ve just fixed your WordPress site’s email delivery issues with SendGrid using WP Mail SMTP.

Next, would you like to set up email logging? Be sure to check out our tutorial on how to log emails that are sent from your WordPress site.