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.