我已经为我们的内容人员编写了一个快速而肮脏的脚本,用于向分发列表发送时事通讯。这个脚本已经工作了几个月了,所以用PEAR邮件程序重写它在我的优先级列表中排名靠后。今天,脚本发送电子邮件失败。error_get_last()函数返回false,电子邮件不会发出,但mail()为空。我该怎么做才能弄清楚为什么脚本突然停止工作?提前感谢!
<?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>");
?>发布于 2012-11-15 23:44:00
发布于 2012-11-15 23:43:01
尝试将此代码添加到mail()函数之前:
error_reporting(E_ALL)另外,尝试运行以下命令:
服务发送邮件状态
服务后缀状态
这将通知我们您正在使用的主要邮件处理程序。
https://stackoverflow.com/questions/13400961
复制相似问题