MDL-40051 core_lib: replaced add_to_log call when failing to send email with an event

This commit is contained in:
Mark Nelson 2013-11-30 16:16:42 -08:00
parent 0b7422f366
commit 362b9a0465
4 changed files with 126 additions and 1 deletions

View file

@ -5830,7 +5830,18 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '',
}
return true;
} else {
add_to_log(SITEID, 'library', 'mailer', qualified_me(), 'ERROR: '. $mail->ErrorInfo);
// Trigger event for failing to send email.
$event = \core\event\email_failed::create(array(
'context' => context_system::instance(),
'userid' => $from->id,
'relateduserid' => $user->id,
'other' => array(
'subject' => $subject,
'message' => $messagetext,
'errorinfo' => $mail->ErrorInfo
)
));
$event->trigger();
if (CLI_SCRIPT) {
mtrace('Error: lib/moodlelib.php email_to_user(): '.$mail->ErrorInfo);
}