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

时间:2019-09-28 16:23:29

标签: php xampp smtp yahoo-mail

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

sendmail.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:\Users\GMKRG\Desktop\xampp\sendmail\sendmail.exe" -t"

;mail.force_extra_parameters =

mail.add_x_header=Off

mail.log = "\"C:\Users\GMKRG\Desktop\xampp\sendmail\error.txt"

;mail.log = syslog

我还配置了yahoo帐户以接受来自安全性较低的应用程序的邮件,但仍未收到邮件。预先感谢。

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

$email = mysqli_real_escape_string($connection, $mailString);
$emailBody = "Please click on the link below to activate your account:\n\n";

$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>";
}

1 个答案:

答案 0 :(得分:0)

似乎yahoo smtp服务器无法与xampp一起正常工作。切换到gmail后,一切正常。