how-to-send-wordpress-emails-using-gmail-smtp-with-wp-mail-smtp_b

How to Send WordPress Emails Using Gmail SMTP with WP Mail SMTP

Looking for a secure SMTP plugin that helps you receive email notifications from your WordPress contact forms? With WP Mail SMTP, you can fix delivery issues by authenticating emails through your Gmail or G Suite account — all while keeping your login credentials safe.

In this post, we’ll show you how to set up WP Mail SMTP for sending WordPress emails with your Gmail or G Suite email address.

Ready to skyrocket your income online through your email list? We’ve compared costs and features of the best email marketing services available today.

Why You’re Not Receiving Notifications

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 not getting emails is that your WordPress hosting server is not configured to use the PHP mail function. Regardless of if you’re using unmanaged or managed WordPress hosting.

WPForms is the best WordPress Form Builder plugin. Get it for free!

In addition to this, anti-spam efforts by email providers can impact your emails as well.

spam blockers cause email to not be delivered

As part of their filtering process, many email providers will check whether your email originates from the same domain noted in the From Email. For example, if your email claims to be sent from your Gmail address but is actually sent from your website’s server (rather than Gmail’s server), your email may be sent to spam or not be delivered at all.

You can fix this by using SMTP instead of the PHP mail function. SMTP (Simple Mail Transfer Protocol) is the industry standard for sending emails reliably.

Want to start your own site? Check out this list of the best website builders for small business.

Why Use the WP Mail SMTP Plugin for Gmail SMTP?

The main benefit of using the WP Mail SMTP plugin is that it lets you send WordPress emails securely using your Gmail or G Suite account without requiring you to enable less secure apps in your account.

In addition, unlike many other SMTP options, you won’t need to enter your Gmail username and password in your WordPress dashboard where other site users can see them. By using this method, you’ll help to keep your WordPress site secure.

Important: If you’re looking for a seamless experience setting up SMTP, our official recommended mailers include:

SendGrid and Mailgun are also reliable options. There tends to be some compatibility issues with Gmail and different site servers, and it isn’t as easy to use as some of the other mailers.

But if you’d still like to use Gmail or G Suite, let’s go ahead and take a look at how to set up WP Mail SMTP for sending WordPress emails using that mailer.

Step 1: Install the WP Mail SMTP Plugin

The first thing you need to do is to install and activate the WP Mail SMTP plugin. For step-by-step instructions, you can check out WPBeginner’s guide on how to install a WordPress plugin.

After installing and activating WP Mail SMTP, go to WP Mail SMTP » Settings and scroll down to the Mail section.

from email

Here, you’ll see the From Email. You can ignore the From Email settings, because Google will automatically force that values to match the email account used in the next step.

Scroll down and you’ll see the From Name setting. This you can customize.

from name settings

The From Name is the name associated with emails sent out, and is set to your site’s name by default. You can adjust this to anything you’d like. You can also check the Force From Name option to apply this setting site-wide.

To start the mailer setup process, you’ll need to scroll down a bit further to the Mailer section and click on the Google option.

select google mailer option in WP Mail SMTP

Important: Gmail’s API (used by the Google mailer) will not allow you to customize certain aspects of your emails, such as the Reply To email address. If this is important to you to control, consider using an alternative mailer option. You may also want to consider a different mailer if you expect to send a high volume of emails, because Gmail’s API has rate limitations and a number of additional restrictions that can lead to challenges during setup.

If you are continuing your Gmail mailer setup and not selecting a different mailer, next we recommend checking the optional Return Path checkbox to Set the return-path to match the From Email. With this enabled, you’ll be emailed if any messages bounce as a result of issues with the recipient’s email.

check set return path

Next, you should see a new Gmail section appear. Here, you’ll see fields for Client ID and Client Secret.

gmail mailer settings

To get the information for these fields, you’ll need to create a web application through your Google account. This doesn’t require any coding, and we’ll show you exactly what to do.

If you’re ready to start selling physical or digital goods on your website, be sure to check out our guide on how to set up a simple order form on WordPress.

Step 2: Create a Web Application for Gmail SMTP

To create an application, you’ll first need to click here then sign in to your Gmail account and access Gmail’s application registration. This link should launch a new tab for you, so keep your WP Mail SMTP settings tab open because we’ll be coming back to those later.

Note: If you’re using G Suite, make sure that the Google account you use has email sending permissions (in other words, access to its own inbox).

Once you’ve followed that link and logged into your Gmail account, you should see a form named “Register your application for Gmail API in Google API Console”.

In the dropdown labeled Select a project where your application will be registered, leave the default option of Create a project. In some cases, you may also be asked to agree to terms of service.

After filling out this form, go ahead and click the Continue button.

create a project

Next, you should see a screen that says “The API is enabled”. To proceed to the setup page, click the Go to credentials button.

enabled the api

In the next page, you’ll be prompted to determine the credentials you need. Here are the fields on this page and the options you’ll need to select:

  • Which API are you using? Gmail API
  • Where will you be calling the API from? Web server (e.g. node.js, Tomcat)
  • What data will you be accessing? User data

Once you’ve made these selections, click the What credentials do I need? button to go to the next step.

add credentials to your project

After clicking this button, Google will show a popup asking you to set up a consent screen. Go ahead and click on the Set Up Consent Screen Option.

Open OAuth consent screen

This will open a new tab or window. Be sure to keep the original tab/window open, as we’ll return to it a little later.

In the new tab/window, you’ll be asked for several details to prepare your consent screen. This is the permissions screen that will display to you later in the setup process. It’s never seen by your users.

If you have a G Suite account, you’ll first set the Application type to Internal. However, you will not see this option if you’re using an @gmail.com email account.

select the internal application type

For Application name, you can add the name of your website (or any other name that feels logical to you).

fill in application details

Then, you can skip down to Authorized domains and add the URL for your website. Be sure not to include http:// or https:// here.

For Application Homepage link, Application Privacy Policy link, and Application Terms of Service link, you can again just add your website URL. You don’t need to have special privacy or terms pages in place for this app, as again this consent screen will only ever be seen by you.

add authorized domain info

When you’re ready, click the Save button at the bottom of this screen.

After saving your consent screen settings, Google will take you back to an API credentials screen. You can ignore this, and instead return to the first tab/window.

For this step, you’ll be creating an OAuth client ID. OAuth, or Open Authorization, is what will provide permission for your website to use your Gmail account to authenticate emails.

For the Name field, enter anything you like or leave the default name. This is only for reference within your Google account.

For Authorized JavaScript origins, you’ll need to enter your site’s URL.

Last, we need to fill out the Authorized redirect URIs field. To get the URI for your site, you’ll need to go back to the tab or window with your WordPress site. Still on the Settings » WP Mail SMTP page, you’ll need to look under the Gmail section for the field labeled Authorized redirect URI.

The value in this field should be your site’s URL followed by some extra details. You’ll need to copy this value, which is easily done by clicking the button with the copy icon.

use button copy to authorized redirect path

After copying the URI, return to the Google APIs page and paste it into the field under Authorized redirect URIs.

Note: In order to be certain that Google stores your data, enter the URL and then tap the Enter/Return key. When you see a trash can icon next to the URL, you’ll know it’s been stored and it’s ok to proceed.

Create-OAuth-client-ID-onsite

When you finish filling out these details, you may see a Refresh button near the bottom of the page. Go ahead and click this.

Click Refresh button

Next, you can click the Create client ID button.

Click blue button to create OAuth client ID

You’ve now successfully created a Google web application!

Now we need to see the full details. On the last screen, click I’ll do this later to go to the Credentials page.

click on ill do this later

Step 3: Grant Permissions and Send Gmail SMTP Test Email

On the Credentials page, you can now see the details of the web application you just created. To view Client ID and Client Secret, click the pencil icon.

Click pencil icon to see details

This will open all of the details for your app. On this page, you’ll see the Client ID and Client secret values.

Copy Client ID and Client secret

Each of these will need to be copied into your WP Mail SMTP settings back in your WordPress admin screen.

Note: Be very careful not to copy any extra text or spaces with your Client ID or Client Secret, as this will result in an error in the next step.

copy in your client id and client secret to WP Mail SMTP settings

After saving these settings, the page will refresh. Before Google allows this information to be used to connect to your account, however, you must grant permission.

To do this, scroll to the bottom of this page and click the button labeled Allow plugin to send emails using your Google account.

Authorize plugin to send emails with Gmail

This will open a login screen for Google. Go ahead and log into the account you’re setting this SMTP up with. Then, you’ll see a screen asking for permission for this site to send emails on your behalf.

When you’re ready, click the Allow button to proceed.

allow permissions with google app

Next, you’ll be returned to your WP Mail SMTP settings and a success message will be displayed. Now that the connection is complete, you’re ready to send a test email under the Email Test tab.

Gmail-connection-success-with-WP-Mail-SMTP-new

Once the Test Email tab is open, you’ll need to enter a valid email address and click the Send Email button. Be sure to use an email address you have access to so you can confirm the email is delivered.

Send a test email through WP Mail SMTP

When the test message has been sent, you’ll see a success message at the top of this tab.

WP Mail SMTP test email was sent successfully

You should also soon receive a test email at the email address you entered.

confirmation message

FAQ on Gmail SMTP

Below are some commonly asked questions to help you navigate the Gmail SMTP setup even further.

What If the Gmail SMTP Test Email Fails?

If the SMTP test email isn’t able to send, a debug log will appear with additional details. Here are some of the possible error messages and how to resolve them.

401. That’s an error.
Error: invalid_client

This error appears when the Client ID isn’t able to be read properly. To fix, try copying the Client ID in again and check that there’s no whitespace or extra text.

400. That’s an error.
Error: invalid_request
Missing required parameter: client_id

This error will display when the Client ID field is empty or not able to be read properly. To fix it, copy in the Client ID again and be careful not to add extra text or whitespace.

cURL error 60: SSL certificate problem
This message means that the server is missing a certificate that’s required for SMTP to work. To fix this, you’ll need to contact your site’s hosting provider to ask them to install this certificate (most likely the cacert.pem certificate, though it’s best to ask your host to check).

“code”: 401,
“message”: “Login Required”

If you see this in the debug message, permission still needs to be granted to your use Google account. For instructions on how to fix this, please see Step 3 of this tutorial. Also, be sure to check that the From Email in your SMTP settings matches the email used to setup the Google app.

What If I See a Gmail SMTP Screen Saying “This app isn’t verified”?

When you click the Allow plugin to send emails using your Google account button, Google might display a screen that says “This app isn’t verified. This app hasn’t been verified by Google yet. Only proceed if you know and trust the developer.” But don’t worry — the message is only referring to the app you just created in your own Google account (so you are actually the developer in this case).

To bypass this message, you’ll need to click Advanced and then Proceed.

this app isn't verified error how to fix

What If I Want to Switch to A Different Email Later?

If you’d like to change to a different Gmail/G Suite email address, you’ll need to repeat all tutorial steps above. This includes generating a new Client ID and Client Secret under this other email account.

When you get to the Authorization step (under Step 3), save your settings and then click the Remove Connection button. This will remove the authorization for your original email account and allow you to repeat the authorization steps with the new email.

Remove connection in WP Mail SMTP

Final Thoughts

That’s it! You’ve successfully configured WP Mail SMTP’s Google mailer on your WordPress site.

Now that your emails are sending perfectly, it’s time for explosive website growth. You can start by hosting a giveaway on your website and trying some easy tips to reduce form abandonment.

What are you waiting for? Get started with the world’s best WordPress forms plugin today.

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

Using WordPress and want to get WPForms for free?

Enter the URL to your WordPress website to install.

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 2 million websites choose WPForms as their preferred online form builder.

    Syed Balkhi
    CEO of WPForms

    1. Hi Evan, I apologize for any confusion!

      Please double-check if you have allowed to plugin access your Google account through the API under WP Mail SMTP Settings. If you didn’t allow it, there should be an orange button to allow it.
      However, if this doesn’t help, if you have a WPForms license, you have access to our email support, so please submit a support ticket.

      Otherwise, we provide limited complimentary support in the WPForms Lite WordPress.org support forum.

      Have a good one 🙂

  2. Hey. I’m trying to use WP Mail SMTP with my G Suite account. I have done everything step by step, but when I’m on the page asking Google for authorization on using the plugin, it does nothing. I’ve clicked the “Advance” link and the Google Pop-up appears, then I click “Allow” and its all fine, but back on the WP Mail SMTP Settings Menu the button is still orange, like I didn’t do anything.

    Can I get any help? Thank you!!

    1. Hi Gaby, thanks for reporting this!
      Normally if everything is done according to the tutorial it should work properly. However, when we see the issues like this we recommend trying the connection process from scratch, it is easy to miss something so it’s good to try it again.

      In case it still doesn’t work, and if you have a WPForms license, you have access to our email support, so please submit a support ticket.

      Otherwise, we provide limited complimentary support in the WPForms Lite WordPress.org support forum.

      Thanks, and have a good one 🙂

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.