如何在 xampp 中发送 php 中的电子邮件?

How to send email in php in xampp?

我尝试发送电子邮件。我收到成功消息。但是我的收件箱中没有收到任何电子邮件。是不是因为我把xampp安装在了D盘而不是C盘?这是我的代码:-

<?php

 $to = "bikloo.talukdar@gmail.com";

 $sub = "My Subject";

 $msg = "This is a test message";


 if (mail($to, $sub, $msg))
 {
     echo "Email sent successfully .....";
 }
 else
 {
     echo "Email not sent .....";
 }

?>

我也在php.ini中设置为:

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = bikloo.talukdar@gmail.com
sendmail_path = "\"D:xampp\sendmail\sendmail.exe\" -t"

我在 sendmail.ini 中的设置:

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=bikloo.talukdar@gmail.com
auth_password=*********
force_sender=bikloo.talukdar@gmail.com

我什至允许访问安全性较低的应用程序。我的收件箱中仍然没有收到电子邮件。谁能帮帮我?

我的路径有误

sendmail_path = "\"D:xampp\sendmail\sendmail.exe\" -t"

应该是

sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"