Delayed mailings

Delayed mailings

by Sergio Comerón -
Number of replies: 3
Picture of Core developers Picture of Plugin developers

In our organization when we send a message through a forum with all the subscribed students, the emails arrive with delay times of around 2 hours. We are a small university and a shipment of these characteristics sends approximately 10,000 emails.

Are these times normal for this type of shipment? Do you make these types of shipments?


Thanks!!

Average of ratings: -
In reply to Sergio Comerón

Re: Delayed mailings

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

You need to collect a sample of such delayed mails and study their full headers to find out where they get delayed.

P.S. I won't call a university which sends 10,000 e-mails a dispatch a "small university".
wink
In reply to Sergio Comerón

Re: Delayed mailings

by Andrew Lyons -
Picture of Core developers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Sergio,

Thanks for raising the question. I suspect it's one that others have encountered too.

Firstly I think we need to collect some more information.

When Moodle sends mails from the forum there are many different stages.

  1. Obviously the first step is a user posting the forum post. This doesn't actually send anything immediately.
  2. Typically there is a 30 minute wait after that before the post is considered for sending. This can be skipped by some users.
  3. There is a scheduled task, which is called by the system cron which then picks up and processes all awaiting messages. It sends them to the Mail Transfer Agent (MTA).
  4. The MTA receives all messages and then processes the sending of them.

You can have delays at steps 3, and 4, as well as the likely standard 30 minute wait.

So firstly you need to check your configuration. How often are you running cron. How often is the forum scheduled task scheduled to run? You can check this in Site administration -> Server -> Scheduled tasks -> Forum mailings and maintenance jobs. Check to see how often this is run. The default value is "* * * * *" which means it will run every minute.

You also have to look at how your Moodle cron is actually called. An outside process has to call the cron process within Moodle. In Linux-type environments you'll typically see this in crontab, or cron.d. You can read about how that happens at https://docs.moodle.org/34/en/Cron.

It's quite common to see cron configured to only run every hour or something on older sites, or where the server admin is not the Moodle admin. We would recommend running this much more regularly - for example once a minute. Also, if this is an older installation, then you may find that there is external locking and the Moodle cron is actually only called occasionally. The conversation looks like: The server attempts to get a lock and succeeds - it now calls the Moodle cron; 5 minutes later the server tries to get the lock again but the previous run hasn't finished, so it cancels; repeat for 2 hours; the original Moodle cron run finishes and the lock is released; the server attempts to get a lock and succeeds - it now runs the Moodle cron. That older locking can now be removed as Moodle locks its own cron.

The next steps location to check is the MTA. This is the most likely cause of the delay and it is well beyond the scope of Moodle.

You can configure Moodle to send mail via SMTP, or via Sendmail. Depending on how you host your server (Windows vs. Linux for example) will depend on how you set this. Personally I have always run my own MTA on all Moodle servers which handle queueing and processing of all e-mail. When I worked for a University, these MTAs (we ran Exim) queued the e-mail and passed it to the University's mail server for sending.

A lot of things can go wrong at that stage. One of the most common things I've seen is that people configure their MTA to take as much e-mail as you can throw at it. The problem with this is that the MTA is now trying to send all of that, as quickly as possible, and it ends up exhausting its resources and taking more time. Often it is better to have it queue more mail and process less of it at once. Either way, this is likely an issue for your systems people.

10,000 e-mails really isn't that many and I would not expect a two hour delay. It does suggest some form of mis-configuration.

Hope this helps you in tracking this issue down,

Andrew

Average of ratings: Useful (3)
In reply to Andrew Lyons

Re: Delayed mailings

by Sergio Comerón -
Picture of Core developers Picture of Plugin developers

Hi Andrew, 

lots of thanks!

My cron run every 5 minuts, I think that the problem is at stage 4. My MTA is postfix. I will ask to my System People if the config of the MTA take as much e-mails as you can throw or less.


Again Thanks!