Skip to content

Commit

Permalink
catch Swift_SwiftException when flushing queue
Browse files Browse the repository at this point in the history
  • Loading branch information
radutopala committed Jun 8, 2016
1 parent 5839d9d commit fd3236d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Library/AutomailerSpool.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit fd3236d

Please sign in to comment.