Making sure forum emails are sent

Making sure forum emails are sent

by Gustav W Delius -
Number of replies: 5

Our lecturers are using the news forum in their courses for important emails to their students. They therefore want to be able to get reassurance from me that these posts are really emailed out to all the enrolled students. In order to be able to give this assurance I want to start to log the output from cron.php which does report how many mails were sent out and shows up any error messages.

To have an even easier way of seeing if there was a problem with sending the mails for a particular forum post I propose to set the "mailed" column of the mdl_forum_posts table to 2 instead of 1 in the case of a problem. That would mean that its size would have to be increased from TINYINT(1) to TINYINT(2). No logic within Moodle would have to be changed. Are there any objections to this change? If not I would implement this. But perhaps there are better proposals?

Average of ratings: -
In reply to Gustav W Delius

Re: Making sure forum emails are sent

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I like it. It will enable a "mail report" somewhere to give a quick report about failed email.

The problem with email is that even it was sent successfully doesn't mean it got further than the host machine, but any extra information is useful, especially when the cost is as low as this.

Another simple thing would be to use add_to_log() in forum_cron() (when the mail fails) to add an entry to that student's activity log ... so that if a student complains they didn't get something the teacher can always check in the student's activity log to see if there were any errors. You would just have to temporarily fake $USER->id to be the student before calling that function.
In reply to Martin Dougiamas

Re: Making sure forum emails are sent

by Gustav W Delius -
I have implemented this and committed to CVS, including your good suggestion about adding it to the user's log. The later required an extra optional argument $user to the function add_to_log(). Your suggestion of temporarily changing $USER->id would have updated the user's last login time.
In reply to Martin Dougiamas

logging the sending of emails

by Gustav W Delius -
If there are no objections then I would like to also call add_to_log() in forum_cron() to log the information about the number of users that a post has been successfully emailed to. Currently only errors are logged, not successfull mailings.
In reply to Gustav W Delius

Re: logging the sending of emails

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Just checking - do you realise with all this reporting you need that a "successful mailing" doesn't mean the mail was necessarily sent to the user ... ? It just means the mail was put in a local queue, usually, while the local mailhost then takes care of sending the mail out. A mailrun either completely works, or it doesn't.

Once a mail system is working there is hardly any chance it will stop doing so, so it probably doesn't really justify extra logs on success ... (I've also been coping with large log files recently so this is a sensitive issue smile )
In reply to Martin Dougiamas

Re: logging the sending of emails

by Gustav W Delius -

I certainly agree that these huge log files are a problem sad. Our log table has grown from zero to 12MB in just 2 weeks.