PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 6, 2022

[FIXED] How to use PHPMailer, after 30 May 2022 when "Less secure app" is no longer an option?

 July 06, 2022     gmail, php, phpmailer, smtp     No comments   

Issue

I have been using PHPMailer for a long time to send emails using Google credentials (login and password) by enabling the "Less secure app" option in the Google settings.

As Google is notifying that after 30th May 2022, Google will not allow sending emails using the "Less secure app".

Less secure apps & your Google Account

enter image description here

Is there any other way to send emails using Gmail SMTP from PHPMailer without the "Less secure app" feature?


Solution

What you need to do is switch to XOAUTH2 or to the Gmail API again using Oauth2.

$mail->oauthUserEmail = "[Redacted]@gmail.com";
$mail->oauthClientId = "[Redacted]";
$mail->oauthClientSecret = "[Redacted]";
$mail->oauthRefreshToken = "[Redacted]";

You can't send email with out the users permission. The owner of the gmail account you are trying to send mails from will need to authorize the app once if you store the refresh token you should be able to use it without any issues.

Remember you will need to go though the application verification process with google. As you will be using a sensitive scope.

Using their login and password is no longer an option.



Answered By - DaImTo
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing