We are using Moodle 1.9 running on a Linux box. Very stable configuration.
Last saturday we had a problem at the mail server, and a lot of forum messages could not be delivered. We repaired the mail server, and now is working fine.
However, at the Moodle tables the forum posts look as delivered (mailed=1 at the forum_posts table). All users use the mail digest configuration (one daily mail).
We tried to change mailed=0 for those posts and manually run the cron.php, but the messages became marked again as mailed=1 but not delivered (this time there was no communication with mails server).
The question is: is there any easy way to resend forum messages ?
Thanks in advance,
You've not mentioned the linux operating system 'flavor' OR if Moodle is hosted locally or remotely, so the following might apply ONLY if hosted locally (CentOS or Red Hat Enterprise) and one has full access to the server - including ssh as root user and sendmail config.
Much depends upon mail servers and how one has configured Moodle to handle mail. IF using an SMTP server (mail from Moodle goes directly to the SMTP server in Moodle config), control of the flow of mail is ALL on the SMTP server. SMTP server must be configured to retain failed deliveries in outgoing mail ques for X number of days and to attempt delivery every so often. IF not configured that way and it cleans mailques, only option is to re-post in forum.
IF using local sendmail on the Moodle server itself, typically sendmail (on CentOS and RHE servers) is configured to attempt delivery of failed messages for 5 days IF the outgoing mailques have not been cleared out via some other system (commandline) method.
Qued messages are stored in /var/spool/mqueue. One can view via the command line 2 files related to a single message. One contains the status, the other contains the message. IF the issues related to the receiving mail server are resloved, one can either wait until the config'd time to try again OR one can restart the sendmail via command line:
/sbin/service sendmail restart
Then one could watch logs in a terminal window/session to see if the mail is being delivered or still has issues.
As root user: tail -f /var/log/maillog [ENTER].
One would/should see log references like the following:
[root@hostname mqueue]# tail -f /var/log/maillog
Jun 26 04:02:54 hostname sendmail: p5Q92raa008260: email@example.com, ctladdr=<firstname.lastname@example.org> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=73679, relay=[somedomainname]. [someIPaddress], dsn=2.0.0, stat=Sent (p5Q92rHV004912 Message accepted for delivery)
Watching and/or checking those logs does also give one clues as to mail issues - thus approaches to resolution of problems.
Again, my response qualified and conditional upon running Moodle on a 'Red Hat' flavored server and to which you have access via ssh as root user. If the 'flavor' of the OS is 'other' (like Ubuntu or SuSE), consult related manuals for that OS via Google.
'spirit of sharing', Ken
Thank you Ken. We also host our own Moodle on a CentOS.
The solution to the problem was waiting for the time when the digest mails are distributed. We were not aware of the timezone calculations that the cron.php program does.
You know Antonio, there is something really cool about your post here. You've had a little problem, and it's now been solved (and due to having too much coffee in the last 20 minutes I can actually hear inspector Clousseau in my brain at this point) and you have actually bothered to come back and tell us with the nice little positive word in the subject "SOLVED". Cool.
This is a practice we could benefit from.
Totally agree with Derek! Giving back to open sourced community could be as simple as 'posting back' a solution (or resolution to a problem).
And must apoligize, forgot about EMail distributions from cron job. But, to add just one more thing ... one can 'force' the running of the cron job via URL in a browser: http://[yourmoodle]/[moodledir]/admin/cron.php
That's if there are not overrides for the cron job in Security -> Site Policies
'spirit of sharing', Ken
To add a little extra to this old discussion, but for future reference.
I managed to get a forum post resend by changing the following fields for the message in the mdl_forum_posts table:
- field "mailed" field of the message to 0
- field "created" and field "modified" to the current epoch time, using an epoch converter.