How to Set Up the Google Workspace / Gmail Mailer in WP Mail SMTP

Would you like to use your Gmail or Google Workspace (formerly G Suite) account to fix email delivery issues on your site? WP Mail SMTP’s Google Workspace / Gmail option uses Google’s API to securely authenticate your site’s emails, helping them to arrive successfully in your users’ inboxes.

In this tutorial, we’ll show you how to set up WP Mail SMTP using the Google Workspace / Gmail mailer with your Gmail or Google Workspace email address.

  1. Installing and Configuring the WP Mail SMTP Plugin
  2. Creating a Web App in Your Google Account
  3. Updating the Publishing Status From Testing to Production
  4. Granting Your Site Google / Gmail Permissions
  5. Sending a Test Email
  6. Frequently Asked Questions

1. Installing and Configuring the WP Mail SMTP Plugin

Before getting started, you’ll need to install and activate the WP Mail SMTP plugin.

Once you’ve verified your license, you’re ready to configure the plugin’s settings. You can find them by going to WP Mail SMTP » Settings and looking under the General tab.

General tab SMTP settings

Below, we’ll cover the settings needed for this setup.

From Email

This is the email address that all of your site’s emails will be sent from. You can type your email address into the field provided or select the email address you’d like to use (including any aliases you’ve configured) from the dropdown that appears after you connect your site to the Gmail API in later steps.

Selecting an email address to use as your From Email after setting up the Google / Gmail mailer

The Force From Email option will make it so all the emails sent from your site come from the address you’ve entered or selected.

Note: In order to use multiple Gmail aliases throughout your WordPress site as the From Email address, make sure to leave the Force From Email box unchecked.

From Name

Below the From Email, you can set the From Name. This is the name associated with the emails your site sends out. By default, it will be set to your site’s name, but you can adjust it to anything you’d like.

You can also check the Force From Name option to apply this setting site-wide.

From Name in WP Mail SMTP settings

Mailer

This is where you can choose which mailer you’d like your site to use. Select the Google / Gmail option.

Selecting the Google / Gmail mailer in WP Mail SMTP's settings

Once you’ve chosen this mailer, you should see a new section appear titled Google / Gmail. In this section, there are settings labeled Client ID and Client Secret.

The Google / Gmail mailer settings

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

You’ll be coming back to WP Mail SMTP’s settings page a little later, so for the next step, open a new tab or window in your browser.

2. Creating a Web App in Your Google Account

In the new tab or window you’ve opened, log in to your Google account and open your Google Cloud Console.

Note: Before continuing, be sure to sign out of all other Google accounts besides the account you’ll be using for the SMTP setup.

Also, if you’re using Google Workspace, make sure that the Google account you use has permission to send emails (in other words, access to its own inbox).

If it’s your first time using Google Cloud Console, you may see a popup asking you to select your country and agree to the Terms of Service. Go ahead and do so, then click on AGREE AND CONTINUE to move on to the next step.

Accepting the Google Cloud terms of service

If you’ve logged in to the Google Cloud Console before, you’ll likely bypass the Terms of Service.

Creating or Choosing a Project

First, you’ll need to choose a project to use for your app. You can select an existing one or create a new one.

To do so, click on the projects dropdown in the toolbar at the top of your dashboard.

Opening the Google Cloud projects dropdown

In the popup that appears, select an existing project from the list or click on New Project in the top right corner.

Choosing to set up a new project for an app in Google Cloud

If you selected an existing project, move on to the next step. For a new project, enter a project name and select an organization and location from the dropdowns.

Creating a new project in Google Cloud

Then click on the CREATE button.

Enabling the Gmail API

Next, you need to enable the Gmail API for your project. In your Google Cloud Console sidebar, go to APIs & Services » Library.

Then look under Category and click on Email, or enter “Gmail API” in the search bar.

Opening the Email category in the Google API Library

Click on the Gmail API result.

The Gmail API

On the Gmail API page, click on the blue Enable button.

Enabling the Gmail API

Creating Your Application’s Credentials

After you enable the Gmail API, you should be redirected to the Gmail API Overview page. Here, click on the CREATE CREDENTIALS button.

Creating credentials for the Gmail API

On the next page, Google will ask a few questions to determine the Credential Type you need. From the Select an API dropdown, choose Gmail API.

Select Gmail API

Note: If you don’t see an option for the Gmail API in the dropdown, be sure that you have the Gmail API enabled for your account.

Next, under What data will you be accessing?, select the User data option. Then click the NEXT button to proceed.

Click-next-button

Google will then ask for some basic information about your app.

This section is mostly for personal use since no one else will be using your app. However, some fields are still marked as required:

  • App name: Enter an app name of your choice (e.g., Pattie’s App).
  • User support email: Select your email address from the choices provided.
  • App logo: If you’d like, you can upload a logo for your app. This is optional.

Entering app information in Google Cloud

Finally, add your email address in the Email addresses field. Then click on the SAVE AND CONTINUE button to proceed to the next step.

Click save and continue button

Configuring Scopes (Optional)

This is an optional step that we will be skipping for this tutorial. Scroll down to the end of the Scopes section and click on the SAVE AND CONTINUE button to proceed.

Continuing past the Google Cloud scopes setup

Note: For more information on Gmail API scopes, please see Google’s developer documentation.

Setting Up Your OAuth Client ID

Next, you’ll need to fill out some information about your OAuth Client ID.

From the Application type dropdown, select the Web application option. Once you do so, more fields will automatically populate.

Select web application

You can leave the Name field as the default value or change it to something more relevant. For this example, we’ll keep the default name, Web client 1.

OAuth name

Next, skip the Authorized JavaScript origins section and scroll to Authorized redirect URIs.

Click on the + ADD URI button and input the following: https://connect.wpmailsmtp.com/google/. You can also copy this value from your WP Mail SMTP settings and paste it here if you prefer.

Input for URI

Then click on the CREATE button to complete this step.

Click create button

Once your app has been created, the Your Credentials section will expand to show you your Client ID. There’s no need to copy it now, as you’ll access it from another area in a later step.

Instead, go ahead and click the DONE button at the bottom of the page.

Click done button

3. Updating the Publishing Status From Testing to Production

Google will put your app into Internal mode by default. It’s really important that you switch it to External mode and publish it. Otherwise, your app will be super limited and won’t function properly.

In your Google Cloud Console sidebar, go to APIs & Services » OAuth consent screen. Under User Type, click on the Make External button.

Clicking the MAKE EXTERNAL button to change the publishing status of a Google Cloud app

In the popup window that appears, select the In production option. Then click on CONFIRM.

Setting the Google Cloud app publishing status to In production

Once confirmation is complete, you’ll see that your app’s Publishing status is now In production.

Checking the publishing status of a Google Cloud app

4. Granting Your Site Google / Gmail Permissions

Next, click on Credentials in the left side menu.

Once you’re on the Credentials page, in the OAuth 2.0 Client IDs section you can see the details of the web application you just created. To view the Client ID and Client Secret, click the pencil icon.

Click pencil icon

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

Client ID and client secret

Go ahead and copy both of these values into the corresponding fields in your WP Mail SMTP settings.

Pasting your Client ID and Client Secret in the Google / Gmail mailer settings

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.

Once you’ve added these values, click the Save Settings button at the bottom of the page.

Save settings button

After saving your settings, the page will refresh. You must grant permission before Google allows our plugin to use your Gmail API to send emails.

To do this, scroll to the bottom of the WP Mail SMTP settings 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 in to the account you’re setting up SMTP with.

Next, 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.

Allowing your site to send emails from your Google account

Bypassing Google’s Verification Warning (Free Gmail Users Only)

If you are connecting with a free Gmail account you might see the following screen. Go ahead and click on the Advanced link in the bottom left corner.

Gmail OAuth warning

In the expanded section, click on Go to wpmailsmtp.com (unsafe). Don’t worry, Google only displays this warning because it hasn’t verified your app. There is no need to verify it since you created this app just for your own use.

Gmail OAuth show advanced

Then click on the Allow button as shown above.

5. Sending a Test Email

Next, you’ll be returned to your WP Mail SMTP settings and a success message will be displayed. Once the connection is complete, you’re ready to send a test email. To do so, navigate to WP Mail SMTP » Tools and open up the Email Test tab.

Email Test tab in WP Mail SMTP

Once the Email Test tab is open, you’ll need to enter an email address whose inbox you have access to. Unless you’re sure you’ll only send plain text emails from your site, we recommend leaving the HTML setting ON. Then click the Send Email button.

Click send email button

When the test email has been sent, you’ll see a success message.

WP Mail SMTP test email success message

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

Successful test email from WP Mail SMTP

Frequently Asked Questions

These are some of the top questions we receive about setting up the Google Workspace / Gmail mailer.

What if the test email doesn’t send successfully?

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 it, try copying and pasting your Client ID 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, try copying and pasting your Client ID again and check that there’s no whitespace or extra text.

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, you still need to grant permission for WP Mail SMTP to access your Google account. For instructions on how to fix this, please see Step 4 of this tutorial. Also, be sure to check that the From Email in your SMTP settings matches the email used to set up your Google app.

Request Entity Too Large
Error 413

If you’re seeing this error, it’s likely that files being sent through your forms exceed Gmail’s limit for direct file attachment in emails. This limit is applied to the sum of the message’s text as well as the encoded attachment. To prevent this error, you’ll need to make sure that all files are no larger than 22 MB.

There was a problem while retrieving Auth for gmail: Could not json decode the token

This error is a possible indicator that another plugin (such as UpdraftPlus) is loading a different version of Google’s API on the site, creating a conflict. If possible, the conflicting plugin should be deactivated. Otherwise, it’s recommended that you set up a different mailer.

If none of the above apply, or the test email still isn’t working, your Google account may have the Gmail API disabled. To check on this, follow Google’s guide to enabling an API.

What if I see a screen that says “This app isn’t verified”?

When you click the Allow plugin to send emails using your Google account button in your WP Mail SMTP settings, 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.”

There’s no need to worry, though. This message is only referring to the app that you created in your own Google account, so you are actually the developer in this case.

To bypass this message, click Advanced and then click Go to wpmailsmtp.com (unsafe).

Gmail OAuth show advanced

What if I want to switch to a different email later?

If you’d like to change to a different Gmail or Google Workspace email address, you’ll need to repeat all the 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 (Step 4), save your settings and click the Remove Connection button. This will remove the authorization for your original email account and allow you to repeat the authorization steps with your new email.

Remove connection in WP Mail SMTP

Does the Google Workspace / Gmail mailer support aliases?

Yes, as of July 2020, WP Mail SMTP supports Gmail aliases. For more details on how to set up an alias in Google, check out its guide on how to send emails from an alias.

Can I use the Google Workspace / Gmail mailer if I have 2 Factor Authentication (2FA) enabled on my Google account?

You can definitely use 2 Factor Authentication with WP Mail SMTP’s Google Workspace / Gmail option. However, it’s important to note that if you choose to disable 2FA, or change the password on your account, you’ll need to go through the setup process again.

When authorizing my app, I get the following error message:

Error 403: access_denied. The developer hasn’t given you access to this app.

This message means that your app’s permissions are set to the testing mode in Google Cloud.

To fix this, be sure to switch the mode from testing to production and try authorizing your app one more time.

If I change my password, will I need to reconnect?

Yes, if your password is changed, the existing connection will be invalidated. To fix this, you will need to create a new connection, using your new credentials.

Do I need to submit my app to Google for verification in order for it to work with WP Mail SMTP?

It isn’t required for you to submit your app for verification. However, you’re welcome to do so if you’d like. If you choose to submit your app for verification, you can continue the authorization process in WP Mail SMTP without waiting for Google’s verification.

That’s it! Now you know how to set up WP Mail SMTP’s Google Workspace / Gmail mailer on your WordPress site.

Next, would you like to know how to effectively troubleshoot issues in WP Mail SMTP? Be sure to check out our tutorial on troubleshooting WP Mail SMTP for more details.