问题描述
我正在使用PHPMailer进行新闻稿发送作业。有时,附件或某些其他详细信息不适用于一个特定的电子邮件收件人。在这种情况下,它会引发一个异常,该异常会写入我自己的日志文件中,这很不错,因为它经常清楚地指出出了什么问题。
问题是,完整的脚本停止了,并且所有其他可能具有正确设置的电子邮件也没有发送。
我如何配置它以便在PHPMailer引发异常时不停止整个脚本,而继续直到发送了具有正确设置的for循环中的所有电子邮件?
read * from email_receipients
for each {
$mail = new PHPMailer(true);
try {
//SMTP settings
//..
$mail->Subject = $mailbody_subject;
$mail->Body = $mailbody_html;
$mail->AltBody = $mailbody_text;
$mail->send();
} catch (phpmailerException $ep) {
$ep_mail_send_message = $ep->getMessage();
$ep_mail_send_code = $ep->getCode();
//writes the $ep error messages to a log file
} catch (Exception $e) {
$e_mail_send_message = $e->getMessage();
$e_mail_send_code = $e->getCode();
//writes the $e error messages to a log file
}
} //closes the for each loop
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)