无法从xampp发送邮件

This is what i have done in php.ini:

[mail function]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

in sendmail.ini:

[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=myemailid@gmail.com
auth_password=mypassword
force_sender=myemailid@gmail.com

And here is the code I wanted to run:

 <?php
$to = 'anotheremail@gmail.com';
$subject = 'Hello from XAMPP!';
$message = 'This is a test';
$headers = "From: myemailid@gmail.com
";
if (mail($to, $subject, $message, $headers)) {
   echo "SUCCESS";
} else {
   echo "ERROR";
}
?>

This is showing me SUCCESS as output. But, I am not receiving any email...

Are you using it for a local project ? The code will keep showing error as the mail() function has failed to send the mail. Try setting the sendmail_path variable as

sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

This will send all mails to your xammp directory in folder mailoutput. Like "C:\xampp\mailoutput"