From 05ff0e2af1df5d27d30b03baeace406833053f81 Mon Sep 17 00:00:00 2001 From: Nina Herrmann Date: Tue, 11 Jun 2024 11:59:38 +0200 Subject: [PATCH] added mtrace statement for logging failed mails (#214) --- step/email/lib.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/step/email/lib.php b/step/email/lib.php index f25b78bb..4635aed8 100644 --- a/step/email/lib.php +++ b/step/email/lib.php @@ -121,15 +121,18 @@ public function post_processing_bulk_operation() { $parsedsettings = $this->replace_placeholders($settings, $user, $step->id, $mailentries); - $subject = $parsedsettings['subject']; - $content = $parsedsettings['content']; - $contenthtml = $parsedsettings['contenthtml']; - // TODO: use course info to parse content template! - email_to_user($user, \core_user::get_noreply_user(), $subject, $content, $contenthtml); - $DB->delete_records('lifecyclestep_email', + $subject = $parsedsettings['subject']; + $content = $parsedsettings['content']; + $contenthtml = $parsedsettings['contenthtml']; + // TODO: use course info to parse content template! + $success = email_to_user($user, \core_user::get_noreply_user(), $subject, $content, $contenthtml); + if (!$success) { + mtrace("E-mail to user {$user->id} failed."); + } + $DB->delete_records('lifecyclestep_email', ['instanceid' => $step->id, 'touser' => $user->id, ]); - $transaction->allow_commit(); + $transaction->allow_commit(); } }