2012-04-13 2 views
0

내 서버에서 보내는 전자 메일을 처리하는 루핑 메일러 스크립트가 있습니다. 때로는 다음 오류로 끊깁니다. 메시지의 미리 알림 완료 할 수PhpMailer가 치명적인 예외를 throw했습니다.

PHP Fatal error: Uncaught exception 'phpmailerException' with message 'SMTP Error: Data not accepted.'

이 죽을 내 스크립트를 야기한다.

다음은 이메일을 보내는 코드입니다.

$message = new \PHPMailer(true); 
$message -> IsSMTP(); 
try 
{ 
    $message -> SMTPAuth = true; 
    $message -> Host = Config::HOST; 
    $message -> Port = Config::PORT; 
    $message -> Username = $account; 
    $message -> Password = Config::PASS; 
    $message -> AddReplyTo($account, Config::NAME); 
    $message -> SetFrom($account, Config::NAME); 
    $message -> AddAddress($recipient[0], $recipient[1]." ".$recipient[2]); 
    $message -> Subject = $recipient,$this->subject; 
    $message -> AltBody = 'Please enable HTML viewing in order to view this message. Thank you.'; 
    $message -> MsgHTML($recipient,$this->body); 
    if($attachment !== false) 
     $message->AddAttachment($attachment); 
    $message -> Send(); 
} 
catch (phpmailerException $e) 
{ 
    return $error -> errorMessage(); 
} 
catch (Exception $e) 
{ 
    return $error -> getMessage(); 
}

나는 예외를 포착하지 않는 것 같습니다. 어떻게하면 정상적으로 복구 할 수 있습니까? 아래에 표시된대로

EDIT 그것은 네임 스페이스의 문제였다.

+2

'시도'안에 인스턴스 생성과'IsSMTP()'호출을 시도 했습니까? – Madbreaks

+1

가능한 복제본 [PHP 치명적인 오류를 잡는 방법] (http://stackoverflow.com/questions/277224/how-do-i-catch-a-php-fatal-error) – Treffynnon

+0

@Madbreaks, I 'll 이 일을 시도해보십시오. 그것이 작동하는지 실패를 재현하는 것은 약간의 작업을 필요로 할 것이다. –

답변

1

대부분 네임 스페이스 오류입니다. 오류가 가장 많이 발생합니다.

catch (\phpmailerException $e) 
+0

+1 그게 다야! 감사! –

관련 문제