Enabling the OAuth 2 API to use with your WordPress Mail SMTP plugin

Overview

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. You can do this by logging into your Google account. You have two options.

If you do not wish to use the 'Less secure apps' option, 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.

  1. Log into your Google account
  2. Visit the following link in your Google account.
    If this is the first time you've enabled the API, agree to the terms of service and click Agree and continue.
    If you've enabled this in the past, choose 'Create a project' in the dropdown, then click Continue.
  3. The next screen confirms the API has been enabled.
  4. Click Go to credentials.
  5. In the first dropdown choose 'Gmail API'. In the next choose 'Web browser'. Click the radio button titled 'User data'.
  6. Click What credentials do I need?.
  7. A pop-up displays notifying you that you must first set up an OAuth consent screen. Click 'SET UP CONSENT SCREEN'.
  8. Under Application name, enter the name of your application.
  9. Enter your WordPress URL under 'Authorized domains'.
  10. Press the 'Enter' key to save your domain name.
  11. Click Save.
  12. A pop-up appears. Click 'Create credentials'. From the dropdown, select 'OAuth client ID'.
  13. Under 'Application type' select 'Web application'.
  14. Give a name to this client ID.
  15. Under 'Authorized JavaScript origins', enter your site's full URL and press the 'Enter' key to save.
  16. Copy the 'Authorized redirect URI' from your WordPress dashboard. This can be found when configuring the SMTP plugin. For example:
  17. Click the Create button.
  18. A pop-up displays with your new 'client ID' and 'client secret'.
  19. Log into your WordPress dashboard and open your 'WP Mail SMTP' plugin.
  20. Enter the 'Client ID' and 'Client Secret' in your WordPress plugin.
  21. Click Save Settings.
  22. Click Allow plugin to send emails using your Google account.
  23. 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.

    At first you'll see a message informing you that the APP is not verified. Google states in its Unverified Apps documentation that this isn't necesary for OAuth2 WordPress plugins. It states the following:
    • OAuth-based plugins: 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.
  24. Click 'Advanced'.
  25. Click 'Go to example.com (unsafe)'.
  26. Click Allow.
  27. Click Allow.
  28. A message displays in your WordPress panel confirming the app has been linked to your site.
  29. Click the 'Email Test' tab, then click Send Email.
  30. You should see a success message. Check your inbox to confirm the email arrived.

See also

Did this article answer your questions?

Article last updated PST.