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
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)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.