How to Fix Google Blocking Gmail from WordPress Sites

In recent times, many WordPress site owners have encountered issues with their contact forms and email notifications, particularly when using Gmail accounts. Google has implemented stricter security measures to protect users from potential spam and phishing attacks. As a result, emails sent from WordPress sites to Gmail addresses may be blocked or marked as spam, especially if they originate from shared hosting servers or are not properly authenticated.

This blocking occurs because Google’s security algorithms detect that the emails are not being sent from a trusted source. To ensure the reliability and security of email communications, Google requires proper authentication through protocols such as SMTP (Simple Mail Transfer Protocol) with OAuth 2.0. This process involves configuring your WordPress site to use a more secure method of sending emails, ensuring they are delivered reliably to Gmail accounts without being blocked.

We currently ran into the problem and here is how we got it fixed:

How to Fix the Issue Using the Post SMTP Plugin

To fix this issue using the Post SMTP plugin, follow these steps to set up Gmail API for sending emails:

  1. Create a Project in Google Cloud Console:
  2. Enable Gmail API:
    • Select your project.
    • Navigate to APIs & Services > Library.
    • Search for “Gmail API” and enable it.
  3. Create OAuth 2.0 Credentials:
    • Go to APIs & Services > Credentials.
    • Click Create Credentials and select OAuth 2.0 Client ID.
    • Configure the consent screen by providing necessary details.
    • Choose Web application as the application type.
    • Add the redirect URI provided by Post SMTP (usually found in the plugin’s settings).
  4. Add Test Users:
    • Under OAuth consent screen, add the email addresses of users who will be testing (including your own).
  5. Get Client ID and Client Secret:
    • Copy the Client ID and Client Secret.
  6. Install Post SMTP Plugin:
    • If not already installed, install and activate the Post SMTP plugin in your WordPress site.
  7. Configure Post SMTP:
    • Go to Post SMTP settings in your WordPress dashboard.
    • Choose Gmail API as the mailer.
    • Paste the Client ID and Client Secret into the respective fields.
    • Save the settings.
  8. Authenticate and Grant Permissions:
    • Click the Grant permission with Google button.
    • Follow the on-screen instructions to grant permission.
  9. Send a Test Email:
    • Use the Post SMTP settings to send a test email and ensure everything is working correctly.

By following these steps, you will configure your WordPress site to send emails through Gmail’s SMTP servers using OAuth 2.0 authentication, ensuring that your emails are delivered reliably without being blocked by Google.