Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit 350e5fa

Browse files
committed
Fix #1176: catching all exceptions when sending mails and adding errors to the end report
1 parent 98427bc commit 350e5fa

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

core/src/plugins/core.mailer/class.AjxpMailer.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function mailConsumeQueue ($action, $httpVars, $fileVars) {
196196
$subject = ConfService::getMessages()["core.mailer.9"];
197197

198198
$success = 0;
199-
$error = 0;
199+
$errors = [];
200200
foreach ($results as $emailType => $recipients) {
201201

202202
$isHTML = $emailType == "html";
@@ -208,7 +208,6 @@ public function mailConsumeQueue ($action, $httpVars, $fileVars) {
208208

209209
$body = $this->_buildDigest($workspaces, $emailType);
210210

211-
$success++;
212211
try {
213212
$mailer->sendMail(
214213
[$recipient],
@@ -220,9 +219,8 @@ public function mailConsumeQueue ($action, $httpVars, $fileVars) {
220219
);
221220

222221
$success++;
223-
} catch (AJXP_Exception $e) {
224-
$error++;
225-
$logInfo("Failed to send email to " . $recipient . ": " . $e->getMessage());
222+
} catch (Exception $e) {
223+
$errors[] = "Failed to send email to " . $recipient . ": " . $e->getMessage();
226224
}
227225
}
228226
}
@@ -236,7 +234,7 @@ public function mailConsumeQueue ($action, $httpVars, $fileVars) {
236234
throw new AJXP_Exception($e->getMessage());
237235
}
238236

239-
$output = array("report" => "Sent ".$success." emails");
237+
$output = array("report" => "Sent ".$success." emails", "errors" => $errors);
240238
echo json_encode($output);
241239
}
242240
}

0 commit comments

Comments
 (0)