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.
- Installing and Configuring the WP Mail SMTP Plugin
- Creating a Web App in Your Google Account
- Granting Permissions and Sending Test Email
- 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 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 and From Name
You can leave the From Email and From Name settings, as Google will force the From Email to match the email account you’ll add a little later in this tutorial (later on, you’ll notice this field becomes disabled).
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.
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.
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.
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, you can leave the default option called Create a project. When you’re ready to move forward, click the Continue button.
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.
Determining Your Application’s Credentials
On the next page, you’ll be asked a few questions to help Google determine the credentials you need.
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.
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.
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.
Configuring Your Consent Screen Settings
In the new tab/window, you’ll be asked for several details to prepare your consent screen. If you have a G Suite account, you’ll first set User type to Internal.
Note: If you’re only using a Gmail account, you will not see this User type option (this setting is only needed in G Suite accounts).
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 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.
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.,
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.
Once you’ve completed all the settings on this page, you can click the Save and Continue button to move on.
By default, WP Mail SMTP will set all required scopes for you, so you can leave these settings blank.
When you’re ready to continue, click Save and Continue to move 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.
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 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 https://connect.wpmailsmtp.com/google/. Copy this value by clicking the copy button next to the field.
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 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.
This will refresh the page and generate a new Create OAuth client ID button. Click this to generate the 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.
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.
This will open all of the details for your app. On this page, you’ll see the Client ID and Client secret values.
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.
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.
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.
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.
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.
You should also soon receive a test email at the email address you entered.
That’s it! You’ve now set up WP Mail SMTP’s Google 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.
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.
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.
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).
“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
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.
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.
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.
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 likely haven’t been set to production mode within Google.
To fix this, navigate to the Oauth consent screen settings within your app. From there, scroll to the Publishing Status section and make sure it is set to In production.