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


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.

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

      This opens a page in a new tab.

      oauth consent screen.png
    8. Select the External radio button.
    9. Click the CREATE button. 
    10. Under Application name, enter the name of your application.
    11. Enter your WordPress URL under 'Authorized domains'.
    12. Press the 'Enter' key to save your domain name.
    13. Click Save.
    14. The verification status displays.
    15. Click Credentials in the left menu.
    16. Click 'Create Credentials' in the top menu.
    17. Select OAuth client ID from the dropdown menu.
    18. Under 'Application type' select 'Web application'.
    19. Give a name to this client ID.
    20. Click ADD URI under 'Authorized JavaScript origins' and enter your site's full URL.
    21. 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:
    22. Click the Create button.
    23. A pop-up displays with your new 'client ID' and 'client secret'.
    24. Log into your WordPress dashboard and open your 'WP Mail SMTP' plugin.
    25. Enter the 'Client ID' and 'Client Secret' in your WordPress plugin.
    26. Click Save Settings.
    27. Click Allow plugin to send emails using your Google account.
    28. 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 necessary 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.

    29. Click 'Advanced'.
    30. Click 'Go to example.com (unsafe)'.
    31. Click Allow.
    32. Click Allow.
    33. A message displays in your WordPress panel confirming the app has been linked to your site.
    34. Click the Email Test tab, then click Send Email.
    35. 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.

Still not finding what you're looking for?