Fix Gmail SMTP Errors in WordPress (WP Mail SMTP Guide)

CodePress Academy | Sanjay Kumar Verma | Free WordPress Tutorials in Hindi & 50+ Online Tools 0
Setup WP Mail SMTP in WordPress easily. Fix Gmail “Access Blocked” and App Publish Error issues and make your test email work successfully.

Why WP Mail SMTP?

By default, WordPress uses the mail() function to send emails, which often fails or ends up in spam. WP Mail SMTP solves this by connecting WordPress to a proper SMTP server (like Gmail, Google Workspace, or other SMTP providers). This ensures reliable email delivery. However, Gmail’s security policies sometimes cause issues like “Access Blocked” or “App Not Published,” which we will fix in this tutorial.

Requirements

  • Installed and activated WP Mail SMTP plugin in WordPress
  • A Gmail or Google Workspace account
  • Access to your hosting panel or domain DNS (for SPF/DKIM records)

Step-by-Step Setup (Gmail with OAuth)

  1. 1) Install WP Mail SMTP

    Go to WordPress Dashboard → Plugins → Add New → Search for “WP Mail SMTP” → Install → Activate.

  2. 2) Open Settings

    Go to WP Mail SMTP → Settings. Enter From Email (the Gmail address you’ll use) and From Name.

  3. 3) Select Mailer

    Choose Google / Gmail as the mailer. This requires a Client ID and Client Secret from Google Cloud Console.

  4. 4) Create OAuth Credentials

    1. Open Google Cloud Console, create a project or use an existing one.
    2. Go to APIs & Services → OAuth consent screen. Fill in app name, support email, and add your domain.
    3. Go to Credentials → Create Credentials → OAuth Client ID. Choose Web application.
    4. Add your WordPress redirect URI (shown in WP Mail SMTP settings).
    5. Create credentials and copy the Client ID & Client Secret.
    6. Paste them in WP Mail SMTP → Settings.
  5. 5) Authorize and Connect

    Click Allow plugin to send emails using your Google account. Sign in with your Gmail and approve permissions.

  6. 6) Send Test Email

    Go to WP Mail SMTP → Email Test. Enter any email address and send. If it works, setup is complete.

Fixing Common Errors

“Gmail Access Blocked” or “This App Isn’t Verified”

Google blocks unverified apps for security. If you see this:

  • Fill all details in OAuth consent screen: app name, logo, privacy policy URL, and authorized domain.
  • For private use, you can bypass warning by clicking Advanced → Go to app. For public use, submit for Google verification.

App Not Published / Publish Error

This happens when your OAuth app is not verified or published. Solution:

  • Use Internal app type if only you (the owner) will use it.
  • For External apps, submit verification to Google.

Emails Still Going to Spam?

  • Set up SPF, DKIM, and DMARC records in your DNS.
  • Always use a From email that matches your domain (e.g., info@yourdomain.com).

Quick Troubleshooting Checklist

  • Client ID & Secret entered correctly?
  • Redirect URI exact match?
  • Authorized domain added in Google Cloud?
  • SPF/DKIM DNS records configured?
  • App published or using Internal type?

Optional Code Snippet (Custom From Address)

<?php


// Add to functions.php
add_filter('wp_mail_from', function($original_email_address){
return 'no-reply@yourdomain.com';
});
add_filter('wp_mail_from_name', function($original_email_from){
return 'Your Website Name';
});
?>
Note: Always backup your theme files before editing functions.php.



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Top Post Ad

Bottom Post Ad

Recent Post