Moolde logging of notification email? Where are they?

Moolde logging of notification email? Where are they?

by Dennis Fulton -
Number of replies: 21

Moodle 3.11 on CentOS 8 VPS.

How and were can you log the notification email that Moodle sends out?  When I post to the Announcement Forum and watch Live Logs, I can see Event Context = System and Event Name = Notification Sent.  When I run a Log report there is not a Notification Sent event listed.  Where an how can you find the log of email notifications sent?

Dennis

Average of ratings: -
In reply to Dennis Fulton

Re: Moolde logging of notification email? Where are they?

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
The best place is the logs of the SMTP server through which Moodle is relaying its e-mail notifications. You'll find it under Site administration > Server > Email > Outgoing mail configuration: SMTP hosts (smtphosts).

I see here https://moodle.org/mod/forum/discuss.php?d=418603#p1686774 that yours is the Microsoft Office365 mail server. I don't think they'll allow you to access their logs. That is the downside of being dependent from the BIG.

You've posted a similar question https://moodle.org/mod/forum/discuss.php?d=424330#p1709112 on Tuesday. Is it the same issue as this? Then better "ping" the old post at the same time providing any additional information than multi-posting.
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Moolde logging of notification email? Where are they?

by Dennis Fulton -
I am still trying to figure out why Notification Emails are not going out to all the students from the Announcement Forum. Being able to find a log of notification messages would be a big help. Getting to the SMTP server is not available to me.
In reply to Dennis Fulton

Re: Moolde logging of notification email? Where are they?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I don't think notifications are logged.
In reply to Howard Miller

Re: Moolde logging of notification email? Where are they?

by Dennis Fulton -
That is unfortunate as they show briefly in the Live Log Report, but not in the Log Report.
In reply to Dennis Fulton

Re: Moolde logging of notification email? Where are they?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Wait.... I'm talking rubbish. They're certainly in the database...




In reply to Howard Miller

Re: Moolde logging of notification email? Where are they?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I must admit that I look at the database table for the logs more than I probably should. The built in logs viewer has some limitations.
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Moolde logging of notification email? Where are they?

by Dennis Fulton -

Where in the database?

In reply to Dennis Fulton

Re: Moolde logging of notification email? Where are they?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
table logstore_standard_log, select eventname='\core\event\notification_sent'
In reply to Howard Miller

Re: Moolde logging of notification email? Where are they?

by Dennis Fulton -
Howard, I am trying to learn the mysql commands. Could you tell me what is wrong with this select:

select userid, timecreated, action from mdl_logstore_standard_log where eventname ='\core\event\notification_sent';

This results = Empty set
In reply to Dennis Fulton

Re: Moolde logging of notification email? Where are they?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Try...

select userid, timecreated, action from mdl_logstore_standard_log where eventname ='\\core\\event\\notification_sent';

...or even...

select userid, timecreated, action from mdl_logstore_standard_log where eventname  like '%notification_sent';
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Moolde logging of notification email? Where are they?

by Florian Leupold -
My database does not seem to have entries like this. Is it possible that notifications are not logged when no SMTP server is specified and Moodle uses the "PHP default method of sending mail"?
In reply to Florian Leupold

Re: Moolde logging of notification email? Where are they?

by Randy Thornton -
Picture of Documentation writers

Yes, notifications from PHP sending are stored here too. All email and message system notifications that have an send event will have an entry in the logs.
What is being logged is the notification event, not the actual sending of the email.
In reply to Randy Thornton

Re: Moolde logging of notification email? Where are they?

by Florian Leupold -
Sorry, I don't see what I might be doing wrong. When I send myself a password reset email, there is not any new log entry with eventname ='\\core\\event\\notification_sent' created. Are those possibly not logged then?
In reply to Florian Leupold

Re: Moolde logging of notification email? Where are they?

by Randy Thornton -
Picture of Documentation writers
You can view the list of events in Site administration > Reports > Events list. That is where you can find the type of event, e.g. \core\event\badge_archived which is the eventname value in the log.

From looking at the list, it is clear that that password changes (updates) are logged events, but I don't see an explicit event for sending out the update mail.

I don't think that a password change request is considered a type of notification. I think that only applies to the messaging system type notifications. Perhaps someone else knows exactly.

When you make the password change request and you immediately look at the end of the log, is there any type of entry in the log for that at all?
Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Moolde logging of notification email? Where are they?

by Randy Thornton -
Picture of Documentation writers
When I try this, I seen no event logged at all for the outgoing password request mail, even when Guest access logging is enabled.

So, probably then the only way to know this was sent is in the logs of the email server.
Average of ratings: Useful (1)
In reply to Randy Thornton

Re: Moolde logging of notification email? Where are they?

by Florian Leupold -
Randy, thanks for your effort and confirming this!
In reply to Florian Leupold

Re: Moolde logging of notification email? Where are they?

by Randy Thornton -
Picture of Documentation writers
No problem, Florian. It's a bit surprising that it is not logged, but then there's a number of things, including potentially dangerous things like disabling modules or authentication methods that aren't logged either.
In reply to Randy Thornton

Re: Moolde logging of notification email? Where are they?

by Randy Thornton -
Picture of Documentation writers
Just for the record, the code for this in moodlelib.php says the following:

 // Directly email rather than using the messaging system to ensure its not routed to a popup or jabber.
    return email_to_user($user, $supportuser, $subject, $message, $messagehtml);

So, it does skip the messaging system and its notification events. The same comment appears in a lot of the places that send email directly (eg badges, login failures, self-enrolment). 

The function email_to_user does trigger an event \core\event\email_failed if the email failed to send but apparently not if it succeeds.


Average of ratings: Useful (1)