How to Set Up the Gmail Mailer in WP Mail SMTP

Would you like to use your Gmail or G Suite account to fix delivery issues on your site? WP Mail SMTP’s Gmail option uses Google’s API to securely authenticate your site’s emails, and to help them get delivered successfully.

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

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 got the plugin installed, you’re ready to configure the plugin’s settings. You can find these settings under WP Mail SMTP » Settings, and we’ve outlined each option below:

From Email

This is the email address that all of your site’s emails will be sent from. Once you’ve connected your Gmail account, you can select the email address you’d like to use (including any aliases you’ve configured) from the dropdown that appears.

Note: In order to use a Gmail alias in the From Email field, make sure the Force From Email box is left unchecked.

Adjust From Email in WP Mail SMTP settings

Below the From Email, you can set the From Name. This is the name associated with the emails your site sends out. By default, this will be set to your site’s name, but you can adjust this to any value you’d like. You can also check the Force From Name option to apply this setting site-wide.

Adjust From Name in WP Mail SMTP settings

Return Path

You can leave the Return Path setting as is, as Gmail doesn’t support this functionality (later on, you’ll notice this field becomes disabled).


This is where you can choose which mailer you’d like your site to use. To configure the Gmail mailer, you’ll need to select the Gmail option.

Select Gmail mailer in WP Mail SMTP

Once you’ve chosen this mailer, you should see a new section appear titled Gmail. Under this, there will be settings named Client Secret and Client ID.

Client ID and Client Secret fields in WP Mail SMTP

To generate the information needed 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.

We’ll be coming back to WP Mail SMTP’s setting page a little later, so for the next step you’ll need to 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, you’ll need to sign into your Gmail account and access Gmail’s application registration.

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 logged into your Gmail account, you’ll see a form named Register your application for Gmail API in Google API Console.

For the Select a project where your application will be registered step, a new app will automatically be created for you in Google if you haven’t previously created one.

Then, go ahead and agree to the Terms of Service, and select your Country of Residence from the dropdown menu. If you’d like, you can also optionally choose to receive newsletters from Google Cloud, however this is not required.

Create a new project for Google application

After you’ve configured each of these settings, go ahead and click the Agree and Continue button to move on to the next step.

Once you’ve clicked this button, you’ll see a confirmation message that says The API is enabled. To move forward to the setup page, go ahead and click the Go to credentials button.

Gmail API is enabled

Determining Your Application’s Credentials

On the next page, you’ll be asked a few questions to help Google determine the credentials you need.

Add credentials to Gmail app

We’ve outlined the settings you’ll need to add below:

  • Which API are you using? For our setup, we’ll be using the Gmail API.
  • Where will you be calling the API from? The application will be calling Google’s API from a web server (e.g. node.js, Tomcat).
  • What data will you be accessing? The connection will be accessing User data.

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.

Once you’ve answered these questions, click the What credentials do I need? button.

What Credentials Do I Need button

After clicking this button, Google will show a popup asking you to set up a consent screen. The consent screen will be used later in the setup process when connecting WP Mail SMTP to your Google account, and will never seen by your users.

Click on Set Up Consent Screen to begin the setup process.

Open OAuth consent screen

This will open a new tab or window, but be sure to keep the original tab/window open – 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. If you’ll be using a G Suite account to configure this app, set the User type to Internal.

Or, if you’ll be using a free Gmail account, you can to set the User type to External.

Select internal user type

Once you’ve filled out this section, click the Create button to move to the next step.

This will take you to another page with more settings to configure. We’ve laid out each option below:

App information

Add App Information in Gmail

  • App name: For the app name, you can add the name of your website (or any other name that feels logical to you).
  • User support email: The user support email is designed to be used if any user has questions about their consent. However, since you will be the only person using the consent screen, you can use whatever email you’d like.
  • App logo: The app logo is not required for the setup process, so we’ll leave this blank.

App domain

Add authorized domain information to Google consent

  • Application Homepage link, Application Privacy Policy link, and Application Terms of Service link: You can add your website’s URL (including http:// or https://) for each of these three settings. You don’t need to have special privacy or terms pages in place for this app, since this consent screen will only ever be seen by you.
  • Authorized domains: Similar to the other settings, this will also be your site’s URL, but you’ll need to be sure not to include the site’s scheme (e.g., http:// or https://).

Developer contact information

This section only has a single setting to complete: Email addresses. Go ahead and add in any emails you’d like to be notified about any changes to this Google app.

Developer Contact Information

Once you’ve completed all the settings on this page, you can click the Save and Continue button to move on.

Configuring Scopes

By default, WP Mail SMTP will set all required scopes for you, so you can leave these settings blank.

Scope Settings in Gmail

When you’re ready to continue, click Save and Continue to move to the next step.

Adding Test Users

After you’ve configured your app’s scopes, you’re ready to add test users to your app. To add a new test user, go ahead and click the + Add users button.

This will open up an overlay, where you’ll be able to add add any email addresses you’d like as a test user for your app.

In this section, be sure to add your own email address, otherwise you’ll end up running into a 403 permissions error later on down the line when you authorize your app in WP Mail SMTP.

Once you’ve added your email address, click the Add button to save these settings.

If the test user has been added correctly, you’ll now see your email address under the User Information section.

Now that you’ve added all your test user, go ahead and click the Save and Continue button to move on to the next step.

Setting Up Your OAuth Client ID

After saving your settings, Google will take you to a summary page of your app. 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.

Create OAuth 2.0 client ID


The name will default to Web client 1, but you can enter any name you’d like. This is only for reference within your Google account.

Authorized JavaScript origins

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

Authorized redirect URIs

To get the URI for your site, you’ll need to go back to the tab or window that has your WP Mail SMTP settings open. From there, you’ll need to look under the Gmail section for the field labeled Authorized redirect URI.

The value in this field should read Copy this value by clicking the copy button next to the field.

Copy Authorized Redirect URI

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

Create OAuth client ID

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 you’re ready to proceed.

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

Click Refresh button

This will refresh the page and generate a new Create OAuth client ID button. Click this to generate the client ID.

Create OAuth client ID

This will redirect you to a screen with your Client ID number. However, you’ll need to see the full details to finish your setup. Click I’ll do this later to go to the Credentials page.

Click I'll do this later

3. Granting Permissions and Sending 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

Go ahead and copy both of these values into your WP Mail SMTP settings. Once those have been added, click Save Settings at the bottom of the page.

Client ID and Client Secret in Gmail Mailer

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.

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 up SMTP 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.

Provide permissions to your 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.

Open the Email Test tab in WP Mail SMTP

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.

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

Notice showing the WP Mail SMTP test email sent successfully

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

Successful test email from WP Mail SMTP

Frequently Asked Questions

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, 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, copy in the Client ID again and be careful to not 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, 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 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.

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 another 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.

If the Gmail API is enabled, after following those steps you should see a small green checkbox labeled API enabled.

Check that Gmail API is enabled

What If I See a 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.” There’s no need to worry, though — the message is only referring to the app that you just created in your own Google account (so you are actually the developer in this case).

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

This app isnt verified error

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

Does the Gmail Mailer Support Aliases?

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

Can I use this if I have 2 Factor Authentication (2FA) enabled on my Google account?

You can definitely use 2 Factor Authentication with WP Mail SMTP’s 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 an 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 test mode within Google, but the email address you’re trying to authorize with isn’t listed as a test user within your app.

To fix this, be sure to add your email as a test user and try authorizing your app one more time.

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

During the authorization process, you may come across an error message that says Google hasn’t verified this app. You can continue past this warning by clicking the Advanced option and continue on with the authorization process.

That’s it! You’ve now set up WP Mail SMTP’s Gmail mailer on your WordPress site.

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