我寫了一個快速而髒的腳本,供我們的內容人員發送簡報到分發列表。這個腳本幾個月來一直工作得很好,所以用PEAR郵件程序重寫它在我的優先級列表上一直很低。今天,腳本未能發送電子郵件。 mail()函數返回false,並且電子郵件不會出去,但error_get_last()爲空。我能做些什麼來弄清劇本爲什麼突然停止工作? 在此先感謝!PHP郵件()返回false但沒有記錄錯誤
<?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>");
?>
有沒有PHP錯誤,不要尋找PHP錯誤轉儲。你有服務器上的郵件日誌訪問嗎? – sglessard
看起來服務器不能讓你這樣做,戴夫。 –