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

Overview

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.

The process is split into two parts:

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.

  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, enter a project name and then click the Create button.

  3. Visit the following link after creating your project.
  4. Click the Next button to confirm the project selected.
  5. On the next page, click the Enable button.
  6. From the left-hand menu, navigate to APIs & Services > Credentials.
  7. Click + Create Credentials and select Help me choose from the options that appear.
  8. Select the following:
    • Dropdown: Gmail API
    • Radio buttons: Select the radio button titled User data.
  9. Click the NEXT button.
    OAuth Consent Screen
  10. On the OAuth Consent Screen page, the following sections appear:
    • App information
    • Developer contact information
  11. Configure the following fields 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.
  12. Configure the following field in the Developer contact information section:
    • Email addresses: Enter your email address.
  13. Click the SAVE AND CONTINUE button.
  14. On the Scopes setting page, click the SAVE AND CONTINUE button.

    WP Mail SMTP configures this for you, so you can leave this section as-is.

  15. On the OAuth Client ID page, fill out the fields on the next page as follows:
    • Application type: select Web application from the dropdown.
    • Name: Enter any name you like. This is only used within your Google account.
    • Authorized JavaScript origins: Enter your website URL. For example, https://example.com.
    • Authorized redirect URIs: Copy the URL from your WordPress dashboard. This can be found when configuring the SMTP plugin.
  16. Click the Create button.
  17. On the Your Credentials page, your Client ID is displayed, click the DONE button.
  18. From the left-hand menu, select OAuth consent screen.
    Edit app
  19. On the OAuth consent screen page, click the EDIT APP button next to your application's name.
  20. The following sections appear:
    • App information
    • App domain
    • Authorized domains
    • Developer contact information
    App domain
  21. Under the App domain section, 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 privacy policy link: 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.
    • Application terms of service link: You do not need a specific terms of service link since the consent screen will only be seen by you. Just enter your site. For example, https://example.com.
  22. The remaining sections will be already configured. Scroll down to the bottom of the page, and click the SAVE AND CONTINUE button to proceed.
  23. From the left-hand menu, select OAuth consent screen.
  24. Under Publishing status, click the PUBLISH APP button and confirm.

Connecting WP SMTP Mail to Google via OAuth2

  1. From the left-hand menu, select Credentials.
  2. On the Credentials page, click the pencil icon to the right of your application to view your Client ID and Client secret.
  3. On the next page, your new client ID and client secret are displayed, copy both of these values into your WP Mail SMTP plugin.
  4. On the WP Mail SMTP settings page, paste in the Client ID and Client Secret.
  5. Click Allow plugin to send emails using your Google account.
  6. When the next page opens, 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.

  7. If you’re using a free Gmail account, you may see the screen shown above. To bypass that message, click Advanced on the bottom left corner.
  8. On the bottom left corner, click the link that will appear Go to wpmailsmtp.com (unsafe).
  9. On the next page, click Continue.
  10. When you are returned to the WP Mail SMTP settings page, make any additional configuration selections and click Save Settings.
  11. Click the Email Test tab, then click Send Email.
  12. A success message is displayed. 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?