2013-07-19 34 views

回答

0

你可以捕捉異常機制,繼續與下一個郵件與發佈者Phil PHPMailer的適當的邏輯

使用了異常。嘗試採取以下

require_once '../class.phpmailer.php'; 

$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch 

try { 
    $mail->AddReplyTo('[email protected]', 'First Last'); 
    $mail->AddAddress('[email protected]', 'John Doe'); 
    $mail->SetFrom('[email protected]', 'First Last'); 
    $mail->AddReplyTo('[email protected]', 'First Last'); 
    $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; 
    $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically 
    $mail->MsgHTML(file_get_contents('contents.html')); 
    $mail->AddAttachment('images/phpmailer.gif');  // attachment 
    $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment 
    $mail->Send(); 
    echo "Message Sent OK\n"; 
} catch (phpmailerException $e) { 
    echo $e->errorMessage(); //Pretty error messages from PHPMailer 
} catch (Exception $e) { 
    echo $e->getMessage(); //Boring error messages from anything else! 
} 
+1

謝謝你,它嘗試捕捉工作。 – Sandeep

0

使用可以使用phplist爲批量郵寄用PHP郵件或不 click Here更多

0

在PHP中,您可以通過添加@的功能抑制錯誤顯示。這通常會防止顯示錯誤。
對於你的情況,你可以把代碼在try..catch。在部分,檢查是否所有的電子郵件已經發送;如果不是,繼續下一個。這也意味着您需要一種方式來跟蹤總郵件數量和完成的電子郵件數量。

希望這有助於。

相關問題