PHP mail()返回false,但不记录任何错误

PHP mail()返回false,但不记录任何错误,php,email,Php,Email,我已经为我们的内容人员编写了一个快速而肮脏的脚本,以便向分发列表发送一份时事通讯。这个脚本已经运行了好几个月了,所以用PEAR-mailer重写它在我的优先列表中是很低的。今天,脚本未能发送电子邮件。mail()函数返回false,电子邮件不会发出,但error\u get\u last()为null。我该怎么做才能弄清楚为什么脚本突然停止工作? 提前谢谢 <?php ob_start(); readfile("/html-email/tt-facstaff"); $facstaff_co

我已经为我们的内容人员编写了一个快速而肮脏的脚本,以便向分发列表发送一份时事通讯。这个脚本已经运行了好几个月了,所以用PEAR-mailer重写它在我的优先列表中是很低的。今天,脚本未能发送电子邮件。mail()函数返回false,电子邮件不会发出,但error\u get\u last()为null。我该怎么做才能弄清楚为什么脚本突然停止工作? 提前谢谢

<?php
ob_start();
readfile("/html-email/tt-facstaff");
$facstaff_content = utf8_decode(ob_get_contents());
ob_start();
readfile("/html-email/tt-students");
$students_content = utf8_decode(ob_get_contents());
ob_end_clean();
ob_end_clean();

if($students_content === false || $facstaff_content === false) die("<h4>Failed to decode content.</h4>");
$all_content = $facstaff_content."\n\n".$students_content;

if(isset($_GET["go"]) && $_GET["go"] == "true"){
    $ppl = "redacted";
    $students = "redacted";
    $facstaff = "redacted";

    $subject = "Tech Times for ".date("m/d");
    $headers = "From: \"Tennessee Tech University\" <redacted>\r\n".
        "Reply-to: redacted\r\n".
        "MIME-Version: 1.0\r\n".
        "Content-type: text/html; charset=iso-8859-1\r\n".
        "X-Mailer: PHP/".phpversion();

    $ok1 = mail($students,$subject,$students_content,$headers."\r\nBcc:".$ppl);
    $ok2 = mail($facstaff,$subject,$facstaff_content,$headers);

    if($ok1 && $ok2){
        echo("<html><body><div><h1 style=\"width:800px; margin:40px auto; text-align:center;\">Tech Times has been sent.</h1></div></body></html>");
    }else{
        $error = error_get_last();
        var_dump($error);
        echo("<html><body><div><h2 style=\"width:800px; margin:40px auto; text-align:center; color:#FF0000;\">Failed to send one or both editions of Tech Times!</h2></div></body></html>");
    }
}

echo $all_content;
echo("<html><body><div style=\"width:800px; margin:40px auto; text-align:center;\"><a href=\"/html-email/tech-times?go=true\">Send Tech Times</a></div></body></html>");
?>

尝试在mail()函数之前添加以下内容:

error_reporting(E_ALL)
此外,请尝试运行:

服务发送邮件状态

服务后缀状态

这将告诉我们您使用的主要邮件处理程序

  • 检查服务器上是否正在运行sendmail
  • 检查/var/log/maillog

  • 没有php错误,不要查找php错误转储。你在服务器上有邮件日志访问权限吗?看起来服务器不能让你这么做,戴夫。没有骰子。我认为错误报告已经在别处设置好了。这是一个dev server.maillog包含以下错误:11月15日09:52:11 localhost sendmail[2184]:NOQUEUE:SYSERR(apache):can not chdir(/var/spool/clientmqueue/):权限被拒绝你知道吗,我重新启动了这个VM,我打赌SELinux已经重新启动了。@Dave如果其他条件相同,可能就是这样。