-
Bug
-
Resolution: Cannot Reproduce
-
Major
-
None
-
3.9.17, 3.11.10, 4.0.4
-
MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE
-
10
Hi,
we are using "Upload users" tool to create new student account each year.
This was about ~500 users this year. We are using SMTP connection to Google e-mail which actually sends the invitation e-mails with generated passwords (and it has also a nice feature that I can actually check if each e-mail was really sent).
The problem: after uploading the CSV and creating users, while all users are successfully created, not all the users receive the e-mails and I can see in Gmail
I have spent hours trying to trace the bug originating from admin/tool/uploaduser/index.php and going through user/lib.php/user_create_user and lib/classes/task/send_new_user_passwords_task to lib/moodlelib.php/setnew_password_and_mail.
All I could find is that some of the e-mails won't sent, but the actual number always varies.
I re-checked this several times: uploading e.g. 25 users will result in Gmail only showing 21 sent e-mails, uploading another (different) 25 new users will result in 19 sent e-mails. Even weirder is that those missing (unsent) users are not on the end of the list (so its not the case that always the last X users are missing): they are spread anywhere in that list of created users (and also in the Moodle event log).
- No error is ever found in Cron tasklog (admin/tasklogs.php): all the send_new_user_passwords_task tasks result in success.
- Similarly, no trace of anything going south in Event log (/report/log/index.php). The only two events always generated are \core\event\user_created and \core\event\user_password_updated. I guess the second event is fired from /lib/moodlelib.php/update_internal_user_password(), which is called by setnew_password_and_mail(), which after that executes email_to_user().
- That e-mail sometimes fails, obviously, but no error, warning or extra event (\core\event\email_failed) is ever generated.
But I am at loss as to where should I look beyond this and what exactly is the cause.
One thing that might be related is that we have set smtpmaxbulk config to 50, as when we used the default (1), Gmail blocked the connection after sending around 100-200 e-mails (which makes sense, as each e-mail required separate SMTP connection). But when we used smtpmaxbulk=1 value, at least all the e-mails got eventually send after day or two when Gmail unblocked us. Now, ever since we started using higher value (50), although we do not get blocked, some e-mails never get send.
I suspected that Gmail might be somehow silently rate-limiting the actual sending of e-mails, but this shouldn't happen when 25 users are created. Still, it seems bad practice that Moodle actually tries to send all the e-mails immediately, without any rate-limiting. Shouldn't this be somehow implemented?
What should I do next to find out what is the actual problem?
- will be (partly) resolved by
-
MDL-68138 Setting smtpmaxbulk > 1 doesn't keep SMTP connection alive
-
- Closed
-