PHP mail()返回false,但不记录错误 [英] PHP mail() returns false but no error is logged

查看:107
本文介绍了PHP mail()返回false,但不记录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个快速而肮脏的脚本,让我们的内容人们将通讯发送到通讯组列表。脚本已经工作了好几个月,用PEAR邮件程序重写它已经在我的优先级列表中很低。今天脚本无法发送电子邮件。 mail()函数返回false,电子邮件不会出来,但是error_get_last()为null。我可以做些什么来弄清楚为什么脚本突然停止工作?
提前感谢!

I've written a quick and dirty script for our content people to send out a newsletter to a distribution list. The script has been working fine for months so rewriting it with the PEAR mailer has been low on my priority list. Today the script failed to send out the email. The mail() function is returning false, and the email is not going out, but error_get_last() is null. What can I do to figure out why the script has suddenly stopped working? Thanks in advance!

<?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>");
?>


推荐答案


  1. 检查sendmail是否

  2. 检查/ var / log / maillog

这篇关于PHP mail()返回false,但不记录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆