PHP mail() 函数返回 1,但尽管配置了 XAMPP,但没有发送邮件



在注册步骤的PHP应用程序中,我向用户发送了一封带有验证链接的电子邮件。我在本地主机中使用 XAMPP 来提供页面,我的数据库在另一个设备中,但在同一网络中。当我填写表格并点击注册按钮时,我收到一条成功消息,数据库已更新,但没有收到发送到我的地址的电子邮件。我已经搜索了答案,发现我必须正确配置php.inisendmail.ini才能使其正常工作,我也这样做了,但仍然没有发送邮件。谁能解释为什么会这样?以下是php.inisendmail.ini的配置,因为我的注册没有问题.php因为数据库正在更新。

发送邮件.ini

[sendmail]
smtp_server= smtp.mail.yahoo.com
smtp_port=465
smtp_ssl=ssl
;default_domain=mydomain.com
error_logfile=error.log
;debug_logfile=debug.log
auth_username=mymail@yahoo.com
auth_password=mypassword
pop3_server=
pop3_username=
pop3_password=
force_sender=mymail@yahoo.com
force_recipient=
hostname=

PHP.ini


[mail function]
SMTP= smtp.mail.yahoo.com
smtp_port=465
sendmail_from = mymail@yahoo.com
sendmail_path = ""C:UsersGMKRGDesktopxamppsendmailsendmail.exe" -t"
;mail.force_extra_parameters =
mail.add_x_header=Off
mail.log = ""C:UsersGMKRGDesktopxamppsendmailerror.txt"
;mail.log = syslog

我还配置了我的雅虎帐户以接受来自安全性较低的应用程序的邮件,但仍然没有收到邮件。提前谢谢。

编辑:下面是php邮件功能,以防它提供更多帮助。

$email = mysqli_real_escape_string($connection, $mailString);
$emailBody = "Please click on the link below to activate your account:nn";
$emailBody .= "localhost/website/activate.php?email=" . urlencode($email) . "&key=$activationKey";
if(mail($email, 'Confirm your registration', $emailBody, 'From:'.'myaddress@yahoo.com')){
echo "<div class='alert alert-success'>Thank you for registering. A 
confirmation email has been sent to $email. Please click on the 
activation link inside it to activate your account.</div>";
}

似乎雅虎smtp服务器无法与xampp正常工作。一旦我切换到gmail,一切正常。

最新更新