This article explains how to enable OAuth2 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.
When following these instructions, make sure you're signed into your WordPress site and Google using the same browser.
Make sure you are also only logged into a single Google account.
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 are still not 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.
- The next screen confirms the API has been enabled.
- Click Go to credentials.
- In the first dropdown choose 'Gmail API'. In the next choose 'Web browser'. Click the radio button titled 'User data'.
- Click What credentials do I need?.
- A pop-up displays notifying you that you must first set up an OAuth consent screen. Click 'SET UP CONSENT SCREEN'.
This opens a page in a new tab.
- Select the External radio button.
- Click the CREATE button.
- Under Application name, enter the name of your application.
- Enter your WordPress URL under 'Authorized domains'.
- Press the 'Enter' key to save your domain name.
- Click Save.
- The verification status displays.
- Click Credentials in the left menu.
- Click 'Create Credentials' in the top menu.
- Select 'OAuth client ID' from the dropdown menu.
- Under 'Application type' select 'Web application'.
- Give a name to this client ID.
- Click ADD URI under 'Authorized redirect URI'. Copy the URL from your WordPress dashboard. This can be found when configuring the SMTP plugin. For example:
- Click the Create button.
- A pop-up displays with your new 'client ID' and 'client secret'.
- Log into your WordPress dashboard and open your 'WP Mail SMTP' plugin.
- Enter the 'Client ID' and 'Client Secret' in your WordPress plugin.
- Click Save Settings.
- Click Allow plugin to send emails using your Google account.
- 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. Make sure to log into the Google account you wish to send emails from.
If you're setting up an OAuth-based plugin for a popular platform, such as SMTP for Wordpress, you don't need to go through the verification process.
- Click 'Advanced'.
- Click 'Go to example.com (unsafe)'.
- Click Allow.
- Click Allow.
- A message displays in your WordPress panel confirming the app has been linked to your site.
- Click the 'Email Test' tab, then click Send Email.
- You should see a success message. Check your inbox to confirm the email arrived.