This article explains how to enable OAuth2 authentication in your Google panel to authenticate your WordPress WP Mail SMTP plugin. This allows you to send FROM your Google address using this plugin. The credentials created during this process can be used in any plugin that allows them.
Make sure you're signed into your WordPress site and Google using the same browser while following these instructions.
Make sure you are also only logged into a single Google account. This will help to avoid any configuration issues.
Configure the SMTP plugin in WordPress
First, view the following article for instructions on how to configure the WordPress SMTP plugin for your Gmail address:
Once set up, you will still not be able to send. You now must allow Google to send email from your WordPress site. Proceed with the steps below to enable OAuth2 authentication.
Setting up OAuth2 in your Google account
Now that your WordPress plugin is set up, you must allow Google to send from your site. You can enable this within your Google account.
- Log into your Google account.
- Visit the following link in your Google account.
Set the first dropdown menu to Create a project.
If this is the first time you've enabled the API, agree to the terms of service and click Agree and continue.
- The next screen confirms the API has been enabled.
- Click Go to credentials.
- Select the following:
- First dropdown: Gmail API
- Radio buttons: Select the radio button titled User data.
- Click the What credentials do I need? button.
- A pop-up displays notifying you that you must first set up an OAuth consent screen. Click the
This consent screen is only used during this configuration process. Your users will never see it.
This option appears only if you're logged into a Google Workspace account. You will not see this option if you're using a regular Gmail account.
link. This opens a page in a new tab.
- Select the Internal radio button.
- Click the CREATE button. A new page opens.
- There are three sections on the next page.
- App information
- App domain
- Developer contact information
- Configure the following fields in in the App information section:
- App name: Give your application a name. This can be anything you like.
- User support email: Choose any email you like. This is only used for this configuration process when setting up the consent screen.
- App logo: You do not need to add the logo since this app will not require users to view a consent screen.
- Configure the following:
- Application home page: Add the full URL of your WordPress site into the Application home page field. For example, https://example.com.
- Application terms of service: You do not need a specific policy link since the consent screen will only be seen by you. Just enter your site. For example, https://example.com.
- Click the +ADD DOMAIN button. A field opens for you to enter a domain. Enter the top level domain of your site. For example, if your site is example.com, just enter example.com. However, if your site is on a subdirectory such as blog.example.com, you must still enter example.com.
- Enter your email address into the Developer contact information field.
- Click the SAVE AND CONTINUE button.
- The next page is where you can set Scopes for your application. WP Mail SMTP configures this for you, so you can leave this section as-is. Click the SAVE AND CONTINUE button to proceed.
A summary page displays the information you just configured. You can close out this tab now.
- Back in the first window, you can now add credentials.
- Name: Enter any name you like. This is only used within your Google account.
- Authorized redirect URIs: Copy the URL from your WordPress dashboard. This can be found when configuring the SMTP plugin.
- Press the Enter key in the Authorized redirect URIs field to save the URL.
- Click the Refresh button.
- A trash icon will display to the right of this field when saved.
- A Create OAuth client ID button appears. Click this.
- The next screen displays your Client ID. You need more information to complete this configuration, so click the link to proceed.
- The Credentials page displays. Click the pencil icon to the right of your application to view your Client ID and Client secret.
- A pop-up displays with your new client ID and client secret. Copy both of these values into your WP Mail SMTP plugin
- Back in your WordPress site, paste in the Client ID and Client Secret in your WordPress plugin.
- Click Allow plugin to send emails using your Google account. A pop-up appears.
- On the pop-up, choose the email address you wish to send your WordPress form FROM.
IMPORTANT: The email address you use at this time to log in will be the email address your WordPress form sends FROM. This will override any email address you have configured in your WordPress SMTP form.
You should already be logged into the correct account however, so you should not have to adjust this.
- Click Allow.
- A message displays in your WordPress panel confirming the app has been linked to your site. Click OK.
- You are returned to your plugin. Click the Save and Continue button.
- Several configuration and upgrade options appear. Make your selections and proceed through each page.
- On the last page click Finish Setup.
- Click the Email Test tab, then click Send Email.
- You should see a success message. Check your inbox to confirm the email arrived.