【问题标题】:PHP mail() function returns 1 but no mail is sent despite configuring XAMPPPHP mail() 函数返回 1,但尽管配置了 XAMPP,但没有发送邮件
【发布时间】:2019-09-28 16:23:29
【问题描述】:

在注册步骤期间的 PHP 应用程序中,我正在向用户发送一封带有验证链接的电子邮件。我在 localhost 中使用 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

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

编辑: 下面是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>";
}

【问题讨论】:

  • 你的 sendmail_path 值看起来有点奇怪,是一个 Unix-only 参数。您的 mail.log 参数值应该只是 "C:\Users\GMKRG\Desktop\xampp\sendmail\error.txt"
  • 我已尝试完您的建议,但没有成功,我收到错误消息而不是成功消息。这意味着与发送消息但未被 smtp 服务器选择的初始状态相比,该消息从未发送过。

标签: php xampp smtp yahoo-mail


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2014-07-14
    • 2020-09-24
    • 2020-03-08
    • 2013-06-16
    • 2011-07-26
    • 2014-09-06
    • 1970-01-01
    • 2016-12-20
    • 1970-01-01
    相关资源
    最近更新 更多