2012-11-15 2 views
2

우리 콘텐트 사용자가 뉴스 레터를 배포 목록에 보내도록 빠르고 쓴 스크립트를 작성했습니다. 이 스크립트는 몇 달 동안 잘 작동하므로 PEAR 메일러로 다시 작성하는 것이 내 우선 순위 목록에서 부족합니다. 오늘 스크립트는 이메일을 발송하지 못했습니다. mail() 함수는 false를 반환하고 전자 메일은 전달되지 않지만 error_get_last()는 null입니다. 스크립트가 갑자기 작동하지 않는 이유를 알아 내기 위해 무엇을 할 수 있습니까? 미리 감사드립니다.PHP mail()은 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>"); 
?> 
+0

PHP 오류가 없으므로 PHP 오류 덤프를 찾지 마십시오. 서버에 메일 로그 액세스 권한이 있습니까? – sglessard

+1

서버가 그렇게 할 수없는 것처럼 보입니다, Dave. –

답변

7
  1. sendmail이 서버에서 실행 중인지 확인하십시오.
  2. 확인/var/log/maillog
+1

maillog에 다음과 같은 오류가 있습니다 : 11 월 15 일 09:52:11 localhost sendmail [2184] : NOQUEUE : SYSERR (apache) : chdir (/ var/spool/clientmqueue /) : 권한이 거부되었습니다. –

+1

이 VM과 나는 SELinux가 다시 돌아 왔다고 확신합니다. –

+1

@ 그 밖의 모든 평등은 아마도 그럴 것입니다. – Sammitch

1

한번에 메일하기 전에이 권한을 추가() 함수 : 또한

error_reporting(E_ALL) 

는 실행하십시오 :

service sendmail status

service postfix status

이 사용중인 주요 메일 핸들러의 어떤 정보를 통보 .

+2

주사위가 없습니다. 어쨌든 error_reporting은 이미 E_ALL에 이미 설정되어 있다고 생각합니다. 이것은 dev 서버입니다. –

관련 문제