WPForms Blog

WordPress Tutorials, Tips, and Resources to Help Grow Your Business

How to Setup Reliable WordPress Email Notifications with SendGrid with WP Mail SMTP

by Shahzad Saeed on Jul 3, 2018

Have you noticed that you’re not receiving WordPress emails? Unfortunately, WordPress not sending emails is a common problem, but it’s easy to fix. In this tutorial, we’ll walk you through how to set up WordPress email notifications with SendGrid using WP Mail SMTP.

When Email Notifications Don’t Work

This can be a tricky problem, because you may not notice that WordPress isn’t sending form notifications until people start filling out your form, and their messages don’t reach your email inbox. You might notice form entries in your WordPress dashboard that haven’t been sent to your email, or discover there’s a problem when frustrated visitors reach out to you using social media or other methods.

Here’s what usually causes the problem…

By default, WordPress uses the PHP mail() function to send emails generated by WordPress or any contact plugin like WPForms.

The most common reason for missing these emails is when your WordPress hosting server isn’t configured to use the PHP mail() function.

Thankfully, you can work around this issue by using SMTP.

SMTP (Simple Mail Transfer Protocol) is the industry standard for sending emails. Unlike the PHP mail function, SMTP uses authentication which increases email deliverability. That’s why we recommend using SMTP to send emails in WordPress.

Why Use WP Mail SMTP with SendGrid?

There are many different SMTP services available, but many of these aren’t secure.

While other methods require you to store sensitive login information in your WordPress dashboard, using SendGrid in WP Mail SMTP will keep your email passwords secure.

SendGrid offers a free plan for sending up to 100 per day. For most small businesses and personal websites, that’s plenty. If you need to send more, you will likely need a paid service.

How to Find Your SendGrid API Key

Before we can configure your website to work with SendGrid, we need to set up an account and find your SendGrid API key. This key is a unique identifier and a secret token for authentication that will allow your website to interact with your account at SendGrid.

First, you’ll need to sign up for a SendGrid account. If you visit their pricing page, you can click the Try for Free link to start with a free trial.

Try a free SendGrid account

Note: In SendGrid, they provide a free option limited to 100 emails per day.

To get their free plan, you’ll first need to sign up for their free 30 day trial. At the end of the trial, you’ll be given the choice to continue on a free plan for under 100 emails a day.

Next, you’ll need to fill out a couple forms to create your account and set up a profile.

When creating your SendGrid account, be sure to use the same email address you’d like to set the From Email to in your form notification settings. These emails will need to match in later steps.

Create a new SendGrid account

After creating an account, click the Start button next to Integrate using our Web API or SMTP relay.

sendgrid integrate web API

Next, you’ll be asked to choose a setup method. You can now click the Choose button under the SMTP Relay option.

choose smtp relay for sendgrid setup

Now enter an API key name and then click Create Key.

Create a SendGrid API key

Once the API key has been generated, you’ll be ready to go to the next step. Be sure to leave this page open, as well need this API key a little later.

Copy the SendGrid API key

Using SendGrid with WP Mail SMTP to Fix WordPress Emails

Now we can get started setting up SendGrid with WP Mail SMTP on your WordPress site.

First, install the WP Mail SMTP plugin. Here’s a step by step guide on how to install a WordPress plugin.

While in your WordPress dashboard, go to Settings » WP Mail SMTP.

At the top of this page, you can set the From Email and From Name. By default, these will fill with your site’s admin email and site name.

For the From Email, be sure this is set to the same email address used to set up your SendGrid account.

We also recommend enabling the Force From Email option. Since you will need the From Email in all plugins that send email to match this email address (a requirement in order for SMTP to work), this option will save you the trouble of editing the email settings throughout your site (in all form emails, etc).

Enable the Force From Email option in WP Mail SMTP

You may add any From Name you’d like, and you can also choose to Force From Name to apply this setting site-wide. Unlike From Email, having a specific From Name is not critical to the plugin’s functionality. However, it will help email recipients to easily see where these emails are coming from.

Set a From Name in WP Mail SMTP settings

Then in the Mailer field, select the SendGrid option.

Though optional, we also recommend checking the Return Path option to Set the return-path to match the From Email. That way, you’ll be notified if any messages bounce due to issues with the recipient’s email.

Select SendGrid as mailer in WP Mail SMTP settings and set Return Path

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.

Paste in SendGrid API key and save settings

Once these settings are saved, you’ll be ready to try sending a test email. To do this, click on the Email Test tab.

Send test email in WP Mail SMTP

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

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

WP Mail SMTP test email was sent successfully

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

Test email for WPForms with SendGrid

Let’s finish by verifying the integration we just created. To do this, check the box labeled I’ve updated my settings and then click Next: Verify Integration.

Verify SendGrid integration

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

Verify integration in SendGrid

Once the email has arrived to SendGrid, they’ll let you know with a success message. This may take a few moments to complete.

Success message from SendGrid integration verification

If you’d like, you can stop here and submit a form to test email delivery. However, for long-term delivery success we recommend proceeding to the next steps to verify your domain and whitelabel email links.

Verifying Your Domain

The best way to ensure that your emails continue to deliver successfully over time is to verify your domain. In SendGrid, this is called “whitelabeling”, which means that your emails will appear to come from your own domain rather than SendGrid.

To get started on verification, you’ll need to open Settings » Whitelabels in SendGrid’s left menu or follow this link.

Then, click the + Add Domain button.

Add domain for whitelabel

This will open a new panel, where you’ll need to enter a subdomain to use for whitelabeling. For our example, we’ll use the subdomain “em”.

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

Add new domain whitelabel to SendGrid

You can leave the Automated Security option set to On, then click Save.

Enabled SendGrid automated security and save changes

Saving these settings will cause an overlay to appear. This will let you know that we still need to make DNS changes, which we’ll do in the next step.

SendGrid overlay to remind that DNS must be completed

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

For more details on modifying your site’s DNS, we recommend WPBeginner’s tutorial on DNS settings.

If you have additional questions about DNS or feel unsure about making changes, please contact your site’s hosting provider.

After adding these DNS records, click the Validate Records button. DNS changes can take up to 48 hours to be recognized, so you may need to check back on this later.

In the meantime, let’s continue to the other part of whitelabeling: Email Links.

Whitelabel Email Links

Whitelabeling email links will allow any links in the emails that are sent to use your own domain, rather than SendGrid’s. This will help to further ensure delivery by keeping all links tied to your own site.

To whitelabel email links, return to Settings » Whitelabels in SendGrid’s left menu. Then, click the + Add Email Link button.

Add email link for whitelabel

In the overlay that opens, you’ll need to enter another subdomain to be used in email links. This can be anything you like, though SendGrid’s documentation suggests “link” or “click” as good options.

For this example, we’ll use “link” as our prefix. Then you’ll need to select your domain and Save these settings.

Set up email link whitelabel in SendGrid

Just as we saw in the previous step, an additional overlay will appear reminding you that DNS changes will take up to 48 hours to take effect. Go ahead an click Confirm.

On the next screen, you’ll be provided with two additional DNS records to add to your site.

DNS records to add for email whitelabel

After adding these records to your site’s DNS, you can check back here click the Validate Records button. Remember that this may take a while, so you may need to check back again later.

Note: Be sure to submit a couple of test forms after completing this setup to check that emails deliver successfully.

If you see any issues, we recommend setting the From Email in your form’s notification settings to the same email you set up SendGrid with.

That’s it! When WordPress can’t send emails, you’re able to fix the problem. Now you’re ready to fix WordPress email notifications with SendGrid using WP Mail SMTP.

Looking for more email notification tips? You might also want to check out our guide on How to Send Users Confirmation Emails from WordPress Forms, which will show you how to send a thank you message to anyone who fills out your form.

Don’t have WPForms yet? What are you waiting for? Get started with the most powerful WordPress forms plugin today.

If you like this article, then please follow us on Facebook and Twitter for more free WordPress tutorials.

Comments

  1. Thanks for reading this article – I hope you found it helpful.

    I wanted to let you know about our new WordPress survey plugin that allows you to build interactive polls and surveys within minutes. You also get best-in-class reporting, so you can make data-driven decisions.

    You can get it 100% free when you purchase WPForms Pro plan.

    Get Started with WPForms Today and see why over 1 million websites choose WPForms as their preferred online form builder.

    Syed Balkhi
    CEO of WPForms

  2. I am setting up a local server to build a web site and need to add SMTP services. I am using the WP Mail SMTP with SendGrid API key. All works very well with the exception of any email address with @yahoo.com in it. The emails are held and never delivered by Yahoo.
    Is there something I need to do to register the SendGrid account to allow yahoo to process the deliveries?

  3. Im using this plugin with sendgrid, and email still go to spam for instance when sending to gmail… any idea why what might be?

    1. Hi Branden,

      If your test email for WP Mail SMTP is working, but email is still going to spam, the next step is to check the From Email in whichever plugin on your site is sending the email. In WPForms, for example, you can set the From Email by opening the form builder and going to Settings > Notifications.

      To ensure successful delivery, the email address will need to match in 3 places:

      1) The email address you used to set up the SendGrid account
      2) The From Email in WP Mail SMTP (in WordPress under Settings > WP Mail SMTP)
      3) The From Email in any plugin that sends email

      Hope this helps! If you’d like us to help debug and investigate the issue further, we offer email support for WP Mail SMTP to users with an active WPForms license. Additionally, as a valued WP Mail SMTP user, we offer 20% off your initial purchase 🙂

      Thanks!

  4. I add sendgrid api key as adviced and validate my domain also by add dns but when try to send mail from my website using wp mail smtp with sendgrid api key mail not send , it showed below bug
    Versions:
    WordPress: 4.9.5
    WordPress MS: No
    PHP: 5.6.36
    WP Mail SMTP: 1.2.5

    Params:
    Mailer: sendgrid
    Constants: No
    Api Key: Yes

    Debug:
    Following RFC 1341, section 7.2, if either text/html or text/plain are to be sent in your email: text/plain needs to be first, followed by text/html, followed by any other content. – content;

    1. Hi Dilip,

      We’re sorry to hear that SMTP isn’t working for you yet. When we see issues like this, the best next step is to run back through the tutorial to be certain that nothing might have been missed (redo each step, recopy details, etc).

      After this, if the problem persists, generally the next best thing to try is contacting your site’s hosting provider. Most SMTP issues are a result of server configuration issues, which your host should be able to help resolve.

      If you’d like us to help debug and investigate the issue further, we offer email support for WP Mail SMTP to users with an active WPForms license. Additionally, as a valued WP Mail SMTP user, we offer 20% off your initial purchase 🙂

      Thanks!

  5. Just wanted to say that after much frustration trying to get these forms to function properly this tutorial saved my sanity. Appreciate your attention to detail – was very easy to follow and everything is working like a charm now, thanks!

    1. Hi Mandee,

      Definitely — email issues can be super frustrating. But I’m glad to hear this helped you get things up and running! 🙂

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.