【问题标题】:Sending mail from local apache server fails, no error message given从本地 apache 服务器发送邮件失败,没有给出错误消息
【发布时间】:2015-07-05 18:23:44
【问题描述】:

前言;我浏览了很多主题,按照他们所说的做了,但没有什么对我有用 - 所以我做了这个。

所以我使用 xampp/apache 从 php 文件发送邮件,但我得到的只是“邮件传递失败...”。

有谁知道我做错了什么,或者可能如何显示出错的错误,因为我没有收到任何错误。

这是我的代码.. (出于明显的原因,我审查了我的电子邮件并通过了)

if (!mail("censored@gmail.com", "title", "blahblahblah", "From: me@hotmail.com")) {
die("<p>Message delivery failed...</p>") . mysqli_error();
}
?>

sendmail.ini:

smtp_server=smtp.gmail.com
smtp_port=465
auto = use SSL for port 465, otherwise try to use TLS
auth_username=censored@gmail.com
auth_password=censored

php.ini:

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

如果需要任何其他信息,则超出此范围。

【问题讨论】:

    标签: php apache smtp xampp


    【解决方案1】:

    尝试允许不太安全的应用使用此链接向您发送电子邮件:https://www.google.com/settings/security/lesssecureapps

    【讨论】:

    • 使用某种库,例如,php_libmail 用于通过 SMTP 发送邮件。
    • 我同意@Priler - 使用库。我通常使用 PHPMailer
    • @mikekaperys 好的,所以我正在尝试 phpmailer。但我不断收到“抱歉,没有可显示的内容......”作为我屏幕上出现的唯一内容。知道这是怎么回事吗?我已将 phpmailer 文件夹粘贴到我的 htdocs 中。我正在引用 require("../PHPMailer/_lib/phpmailer-fe.php");
    【解决方案2】:

    SElinux 默认阻止来自 web 服务器的发送邮件,将 SElinux 中的设置更改为:

    setsebool -P httpd_can_sendmail on
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-26
      • 2018-04-22
      • 1970-01-01
      • 2018-05-09
      • 2010-11-04
      • 1970-01-01
      • 2014-05-06
      相关资源
      最近更新 更多