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


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.

  1. Log into your Google account.
  2. 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.

  3. The next screen confirms the API has been enabled.
  4. Click Go to credentials.
  5. Select the following:
    • First dropdown: Gmail API
    • Second dropdown: Web browser (Javascript)
    • Radio buttons: Select the radio button titled User data.
  6. Click the What credentials do I need? button.
  7. A pop-up displays notifying you that you must first set up an OAuth consent screen. Click the SET UP CONSENT SCREEN link. This opens a page in a new tab.
    oauth consent screen.png

    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.

  8. Select the Internal radio button.
  9. Click the CREATE button. A new page opens.
  10. There are three sections on the next page.
    • App information
    • App domain
    • Developer contact information
  11. 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.
  12. 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: 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.
  13. 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
  14. Enter your email address into the Developer contact information field.
  15. Click the SAVE AND CONTINUE button.
  16. 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.

  17. 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 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.
  18. Press the Enter key in the Authorized redirect URIs field to save the URL.
  19. Click the Refresh button. 
    A trash icon will display to the right of this field when saved.
  20. Create OAuth client ID button appears. Click this.
  21. The next screen displays your Client ID. You need more information to complete this configuration, so click the I'll do this later link to proceed.
  22. The Credentials page displays. Click the pencil icon to the right of your application to view your Client ID and Client secret.
  23. A pop-up displays with your new client ID and client secret. Copy both of these values into your WP Mail SMTP plugin
  24. Back in your WordPress site, paste in the Client ID and Client Secret in your WordPress plugin.
  25. Click Allow plugin to send emails using your Google account. A pop-up appears.
  26. 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.

  27. Click Allow.
  28. A message displays in your WordPress panel confirming the app has been linked to your site. Click OK.
  29. You are returned to your plugin. Click the Save and Continue button.
  30. Several configuration and upgrade options appear. Make your selections and proceed through each page.
  31. On the last page click Finish Setup.
  32. Click the Email Test tab, then click Send Email.
  33. 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?