From fd3236d6508b5a53fdafef3a580fb89b9d7fcb0e Mon Sep 17 00:00:00 2001 From: Radu Topala Date: Wed, 8 Jun 2016 13:56:54 +0000 Subject: [PATCH] catch Swift_SwiftException when flushing queue --- Library/AutomailerSpool.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Library/AutomailerSpool.php b/Library/AutomailerSpool.php index 13e9fc5..5c8c12d 100755 --- a/Library/AutomailerSpool.php +++ b/Library/AutomailerSpool.php @@ -159,15 +159,21 @@ public function flushQueue(\Swift_Transport $transport, &$failedRecipients = nul reset($mails); foreach ($mails as $mail) { - if ($transport->send($mail->getSwiftMessage(), $failedRecipients)) { - ++$count; - $mail->setIsSending(false); - $mail->setIsSent(true); - $mail->setSentAt(new \DateTime()); - } else { + try { + if ($transport->send($mail->getSwiftMessage(), $failedRecipients)) { + ++$count; + $mail->setIsSending(false); + $mail->setIsSent(true); + $mail->setSentAt(new \DateTime()); + } else { + $mail->setIsSending(false); + $mail->setIsFailed(true); + } + } catch (\Swift_SwiftException $e) { $mail->setIsSending(false); $mail->setIsFailed(true); } + $this->save($mail); if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) {