Posting announcement trigger Moodle abnormally send duplicated email to students via SMTP server every 30 minutes for 20 minutes

Re: Posting announcement trigger Moodle abnormally send duplicated email to students via SMTP server every 30 minutes for 20 minutes

by Ariden Lei -
Number of replies: 6
The special characteristics of the affected course is that it enrollment added a metalink of another course which enrolled all staff and students of the university. This second course enrolled cohort sync of 80 UG cohorts and a metalink of PG course. This PG course includes another 30 cohort sync of another PG cohort. It is strange that this course does not have any problem.

Another special characteristics of the affected course is that its announcement were parsed with poster, say 300KB~400KB jpg image.
In reply to Ariden Lei

Re: Posting announcement trigger Moodle abnormally send duplicated email to students via SMTP server every 30 minutes for 20 minutes

by Ariden Lei -
We observed that the affected user accounts are the first 137 accounts to which notification email sent at the earliest time. Moodle would sent duplicated email to them. Moodle normally sends one notification email to the rest of email account. It seems that the problem is not related to timeout but initial state instead.

We added the below MPM directive before. ServerLimit 25
StartServers 3
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 32
MaxRequestWorkers 800
MaxConnectionsPerChild 10000
Would the problem cause be StartServers too small?
In reply to Ariden Lei

Re: Posting announcement trigger Moodle abnormally send duplicated email to students via SMTP server every 30 minutes for 20 minutes

by Ariden Lei -
We found the below error message is output from the cron task.

Execute adhoc task: mod_forum\task\send_user_notifications
... started 00:18:33. Current memory use 9.8MB.
Sending messages to 195197 (19869)
Error: lib/moodlelib.php email_to_user(): The following From address failed: null@smtp.XXXX.edu : Called MAIL FROM without being connected,,,SMTP server error: Called MAIL FROM without being connectedSMTP server error: Called MAIL FROM without being connected
++ Error calling message processor email ++
* line 502 of /lib/classes/message/manager.php: call to debugging()
* line 380 of /lib/classes/message/manager.php: call to core\message\manager::call_processors()
* line 348 of /lib/classes/message/manager.php: call to core\message\manager::send_message_to_processors()
* line 346 of /lib/messagelib.php: call to core\message\manager::send_message()
* line 369 of /mod/forum/classes/task/send_user_notifications.php: call to message_send()
* line 153 of /mod/forum/classes/task/send_user_notifications.php: call to mod_forum\task\send_user_notifications->send_post()
* line 286 of /lib/cronlib.php: call to mod_forum\task\send_user_notifications->execute()
* line 166 of /lib/cronlib.php: call to cron_run_inner_adhoc_task()
* line 76 of /lib/cronlib.php: call to cron_run_adhoc_tasks()
* line 61 of /admin/cli/cron.php: call to cron_run()
Post 40776 sent

What is the problem of the "From address"? What is the meaning of "Called MAIL FROM without being connected,,,SMTP server".
Why can't the sender email address connect to the SMTP server?

Please advise. Thanks a lot!
In reply to Ariden Lei

Re: Posting announcement trigger Moodle abnormally send duplicated email to students via SMTP server every 30 minutes for 20 minutes

by Ken Task -
Picture of Particularly helpful Moodlers

Moodle isn't a mail server.  Your site is configured to use an smtp relay.   From what you've shared sounds like moodle is trying, but the smtp server isn't responding.

From your moodle server and command line, see if you can ping the smtp server.    That shows the NIC is up.   Also, if you had nmap installed on your moodle server, one could see if the smtp service port is available ... let's say port is 765 ... nmap command would be:

nmap -P0 -p 765 smtp.xxx.edu

If that port is opened it will tell ya that.

In the SMTP setup, there is a user and password.  Is that user still valid?

You could also install a plugin to test:

https://moodle.org/plugins/local_mailtest

Basically, you need to contact whomever admins the stmp server as your moodle appears to be trying to send, but ...

'SoS', Ken

In reply to Ken Task

Re: Posting announcement trigger Moodle abnormally send duplicated email to students via SMTP server every 30 minutes for 20 minutes

by Ariden Lei -
The smtp server admin says that SMTP username and password are not needed for sending email. We are using qmail as smtp server.
I found that the cron always prompts "Skipping processing of adhoc tasks. Concurrency limit reached". The adhoc task is for sending forum notification email. Therefore, I increase the "Adhoc task concurrency limit" from 3 to 10. If this value is set large, I found that the CPU and memory would be easily overloaded.
In reply to Ariden Lei

[Solved]: Posting announcement trigger Moodle abnormally send duplicated email to students via SMTP server every 30 minutes for 20 minutes

by Ariden Lei -
After debugging with the error message of cron task, the problem of duplicated email is apparently solved by the below actions:
1. unenrol the metalink of "Staff and students" and re-enrol the metalink. About 1000 suspended accounts are removed

2. Increase the Extra PHP memory limit from 1024M to 4096M
(Reason: It is noticed that duplicated email would be sent if this value is set to lower than 3072M)
PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 10485792 bytes) 

3. Increase the Ad hoc concurrency limit from 3 (default) to 20
(Reason: because no email is sent out sometimes. ) Would this value abnormally increase the Moodle memory consumption?
The cron task shows the message: "Skipping processing of adhoc tasks. Concurrency limit reached."
I refer to the post https://moodle.org/mod/forum/discuss.php?d=388490

4. use a valid email account with rule to drop incoming email for No-reply email address
(Reason: The cron task shows the error message: "The following From address failed: null@yyyy.xxxx.edu: MAIL FROM command failed,,, SMTP server error: MAIL FROM failedSMTP server error: MAIL FROM command failed")

Athough no duplicated email are sent, it is strange that the memory consumption of Moodle seems to be increased from 67GB to 100GB. Is it normal?
Average of ratings: Useful (1)
In reply to Ariden Lei

Re: [Solved]: Posting announcement trigger Moodle abnormally send duplicated email to students via SMTP server every 30 minutes for 20 minutes

by Ariden Lei -
It is real that gradual and minor increase in memory consumption is observed. The memory consumption would be saturated and makes the Moodle to be overloaded. Is there any advice?