0

Hello guys I'm using xampp in sending mail using mail() but I think i need to turn off the less secure app but since google removed it anyone know any alternative to make the code run.

<?php
            $receiver = "2020@gmail.com";
            $subject = "Email Verification Code";
            $message = "Your verification code is ";
            $sender = "From: NatsuDragneelxd42069@gmail.com";
            if(mail($receiver, $subject, $message, $sender))
            {
                echo "Email sent successfully to $receiver";
            }
            else
            {
                echo "Sorry, failed while sending mail!";
            }   

?>

modified php.ini and sendmail.ini

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = my-gmail-id@gmail.com
sendmail_path = "C:\xampp\sendmail\sendmail.exe -t"

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=my-gmail-id@gmail.com
auth_password=my-gmail-password
force_sender=my-gmail-id@gmail.com

please comment if you know alternative to the less secure app or if you spot error in the code.

FallenMoon
  • 11
  • 2

2 Answers2

4

No.

Google removed support for less secure apps.

They didn't remove one way of enabling it while leaving a backdoor that would make the deprecation pointless.

If you want to use GMail as your email backend, use their API. If you want to continue using SMTP then you'll need to find a different email service.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

Google Workspace has been migrating to Oauth 2.0 protocol almost all of their service, even gmail soon wont accepts protocols like IMAP to check mails an smtp will be accepted, but seems like SMTP is goint to be deprecated some day soon

Google and Microsoft announced basic authentication deprecation for their email services in 2022. Both companies consider Basic authentication as an outdated industry standard and thus they are suggesting its customer moving to OAuth 2.0 token-based authorization.

source:Article Deprecation Basic Auth

maybe could help you this Tutorial Tutorial use of Oauth to send

Daniel Perez
  • 43
  • 10