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? SendGrid is a popular and affordable option for WordPress users.

In this tutorial, we’ll walk through how to set up the SendGrid mailer for 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. Furthermore, 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 100 emails per day. For most small businesses and personal websites, that’s plenty. If you need to send more emails, though, you will 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.

Configuring Your SendGrid Account

In order to connect your website with SendGrid, you’ll first need to set up a SendGrid account and create a sender identity.

Creating Your 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 process will be the same no matter which plan you choose.

The SendGrid pricing page

Next, SendGrid will ask you to create your account’s username and password.

The SendGrid signup page

Then SendGrid may ask you some additional questions about your business to help personalize your account.

Entering more details to set up a SendGrid account

Fill out all the required fields, then click Get Started! to continue.

Creating Your Sender Identity

In order to start sending emails with SendGrid, you’ll need to set up a sender identity. There are two options: creating a Single Sender identity or authenticating your website’s domain.

We recommend authenticating your domain, as this method is better for ensuring your emails are delivered consistently. However, we’ve covered both options below.

Adding a Single Sender to Your SendGrid Account

Note: Although you can get your SendGrid integration up and running with a Single Sender identity, this option will not ensure email delivery. We recommend authenticating your domain instead.

In SendGrid, you can create a Single Sender to set up an approved sender email address. To do so, go to your SendGrid account dashboard and look under Create a sender identity. Click the Create a Single Sender button.

Creating a Single Sender identity in SendGrid

Or, go to Settings » Sender Authentication in the SendGrid dashboard menu.

Accessing the sender authentication settings in SendGrid

Then click on Verify a Single Sender.

Verifying a Single Sender in SendGrid

Either of these options will open a panel where you’ll need to enter the sender’s name, email, and physical mailing address. Click on Create once you’ve added all the required information.

Creating a Single Sender in SendGrid

A confirmation message will be sent to the email address you entered. Click on the link in that message to verify your email and finish setting up your Single Sender identity.

Authenticating Your Domain in SendGrid

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 be added to your emails.

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

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

In the Create a sender identity section of your SendGrid dashboard, click on Authenticate a domain instead.

Authenticating a domain in SendGrid

You can also go to Settings » Sender Authentication in the SendGrid dashboard menu and click on the Authenticate Your Domain button to access the necessary settings.

Authenticating a domain in SendGrid

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 sent from your site 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.

Once you’ve answered these questions, click the Next button to continue.

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

Entering the domain to authenticate in SendGrid

After entering your domain, click on Advanced Settings. You’ll need to 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).

SendGrid's domain authentication advanced settings

A subdomain replaces the “www” part of your website’s address (e.g., 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.

Note: The subdomain can be anything you’d like. However, SendGrid recommends:

  • Not using “mail,” as many hosting companies already use this subdomain and it could cause conflicts.
  • Not including any underscores (_) as this character 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 to your site’s DNS settings.

DNS records to add to your domain's settings to authenticate it in SendGrid

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, 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 authenticate your domain, you’ll need to add these 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.

Note: If your DNS is managed by GoDaddy, then you’ll have to 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 unit your DNS uses).

After adding all the DNS records, check the box in your SendGrid dashboard labeled I have added these records. Then click the Verify button. It can take up to 48 hours for DNS changes 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

Generating an API Key

After you’ve created an account and set up your sender identity, you can generate an API key to connect your site to SendGrid and start sending emails. In your account dashboard, click on Email API » Integration Guide in the menu on the left.

Accessing the email API integration options for SendGrid

Next, 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 click Create Key.

Create API key for SendGrid

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

API key for SendGrid account

Setting Up WP Mail SMTP

Now that your SendGrid account is prepped, you can switch over to your website and set up WP Mail SMTP.

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

Once WP Mail SMTP is installed, click on WP Mail SMTP in the WordPress menu on the left side of the admin area to open the plugin’s settings.

The WP Mail SMTP settings page

We’ll discuss each of the options 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, such as in your form notification emails.

The Force From Email setting

From Name

By default, the From Name will be set to your site’s 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.

The Force From Name setting

Mailer

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

Selecting the SendGrid mailer

API Key

Once you’ve chosen SendGrid as your mailer, you’ll need to enter the API Key for your account. Go ahead and flip back to the browser tab or window where your SendGrid account is open and copy the key you generated in the previous step.

Then return to your WP Mail SMTP settings and paste the key into the API Key field.

Adding an API key for SendGrid to the WP Mail SMTP settings

Leave your SendGrid API key page open, as you’ll need to return to this screen again later in this tutorial.

Sending Domain

The Sending Domain setting is an optional setting that will allow WP Mail SMTP to check for any domain-side errors in your SendGrid setup (e.g., incorrectly configured or missing Sender Policy Framework (SPF) records). This domain check will run each time you send a test email, and will only show an error if a misconfiguration is detected.

The sending domain should match the subdomain you authenticated in SendGrid. You can copy and paste this value here.

Note: Make sure you add your entire SendGrid domain to this setting (e.g., sg.wpmailsmtp.com).

Entering the sending domain for SendGrid in the WP Mail SMTP plugin settings

Once you’ve finished configuring your settings, be sure to click the Save Settings button at the bottom of the screen.

Verifying SendGrid Integration

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

Sending a Test Email

In your WordPress admin menu, click on WP Mail SMTP » Tools. Then select the Email Test tab.

Accessing the email test tool

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

Sending a test email with WP Mail SMTP

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

Notice showing the WP Mail SMTP test email sent successfully

If you check the inbox for the email address you entered, you should see the email for this test.

a successful test email from WP Mail SMTP

Verifying Domain Authentication

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

In Gmail or G Suite, click the small arrow under the sender details for your WP Mail SMTP test email.

Expanding the sender details for an email in Gmail

This should open more details about the email header. From here, check that the mailed-by value matches your subdomain (e.g., sg.wpmailsmtp.com). Then check that the signed-by value matches your regular site domain (e.g., wpmailsmtp.com).

Checking that your domain has been authenticated in SendGrid by looking at the test email sender details in Gmail

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 recommend waiting at least an hour, then repeating this test process.

Verifying Integration in SendGrid

After your test email has been sent successfully, you’ll need to go back to your SendGrid account’s API page. Here, check the box labeled I’ve updated my settings and 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.

Verifying integration in SendGrid to finish connecting it to your website

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

Frequently Asked Questions

These are the top questions we get from users regarding the SendGrid mailer.

How can I check if my API Key has the Mail Send access level in SendGrid?

To check that the API key you’ve created has the correct access level configured, first navigate to Settings » API Keys within your SendGrid account. This will bring you to a page with all of your available API keys. Click the gear icon to open up a specific key’s settings.

Opening the SendGrid API key settings

In the key settings, be sure that the Restricted Access option is selected.

Enabling restricted access for a SendGrid API key

Once this option is selected, additional permissions will appear for you to configure. Scroll down to the Mail Send setting and be sure the permission level is set to Full Access.

Checking that mail send permissions are set to full access in SendGrid

That’s it! Now you can fix 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 for more details.