Mass sending emails silently fails and reports as success
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start with /classes/task/process_workflows.php, especially process_queue and process_item, and trace how email_action_step reports send failures and reaches the existing retry handling. Check the Moodle email sending result and the task log described in the issue; done means failed sends are reported as workflow failures, retried according to the configured limit, and email rate limiting applies only to email tasks.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello,
we have a program where we enrol ~400 new students each year. Every student receives two e-mails:
- an automatic Moodle e-mail about creation of new account – managed by Moodle itself
- an invitation e-mail telling students that they have been enrolled to a new course – sent by Event trigger using User enrolled event (
\core\event\user_enrolment_created)
Because of the aggressive way in which Moodle sends the first kind of email (trying to send as much as possible in one batch without any rate limiting), our mail provider (currently Gmail account set up through SMTP) starts rejecting new email after around 100 emails are sent in literally two or three minutes. This is obviously Moodle's unwise approach, but that's not the problem. These e-mails fail to send and Moodle re-tries it later, until it eventually manages to send all of them, which is sort of fine.
However, second type of e-mails, sent by Event trigger, report success even when they were not sent. As soon as the e-mail provider starts limiting new e-mails to be sent, \core\event\email_failed event is generated in system (instead of normal \core\event\notification_sent when the sending of e-mail is successful), but the Event Trigger plugin reports the workflow as successful and there was no attempt whatsoever to resend the e-mail at any point in the future (at least to my knowledge according to system logs).
I have spent last few days trying to debug this, both in connection with first kind of e-mails, and both isolated. This is what I have found out:
- When I skipped sending first kind of e-mails (about creation of new account), and only tested sending Event Trigger invitation e-mails to 200 testing accounts after enrolling them to a course, Event Trigger still got "banned" after sending around 50 emails in less than one minute. So this is an isolated problem of Event Trigger plugin, although it gets worse when combined with Moodle sending its own e-mails. Event Trigger itself should somehow limit its rate of sending e-mails (and preferably, this limit should be configurable by system admin, because it might depend on e-mail provider).
- However, when I decreased maximum number of tasks processed in one Event Trigger queue by setting
const LIMITQUEUEdown to 20 in/classes/task/process_workflows.php@66, the plugin was able to successfully send 200 e-mails in around 16 minutes and not a single one was dropped. So this obviously works to limit the rate of sending e-mails, but it limits all Event Trigger tasks, which is both undesirable and drastic, and in some Moodle installations with lots of workflows in might lead to Event Trigger never finishing its tasks. - Moreover, the error in sending e-mail does not get detected in Event Trigger during processing of workflow with
email_action_step. The Moodle system itself detects the error (both by generating\core\event\email_failedevent and in Cron task log – see below), but the Event Trigger plugin somehow misses the error.
What needs to be done:
- Event Trigger plugin should limit its rate of sending e-mails (and preferably, this limit should be configurable by system admin, because it might depend on e-mail provider). This limit should be imposed only to e-mails send, and not to other types of tasks (i.e., not by simply lowering
LIMITQUEUE). This should be relatively easy to do by counting the number of e-mail tasks (steps of classemail_action_step) inprocess_queueandprocess_itemmethods. - Event Trigger should report workflow as failed when sending e-mail fails. Currently,
- View workflow history states that workflow passed all steps,
- View step information does not show any error either,
- Cron log shows the Process workflows scheduled task (
\tool_trigger\task\process_workflows) as successful, - however, the tasklog of specific Cron task shows this error:
which means that there definitely is a way to detect error directly during sending e-mail, it is only improperly treated (or ignored).Execute workflow step: 38, \tool_trigger\steps\actions\email_action_step Error: lib/moodlelib.php email_to_user(): SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
- Event Trigger should retry the step when sending e-mail fails. There is already an exception catch programmed in
process_itemmethod of/classes/task/process_workflows.php(and there was also aMAXTRIESconstant, now replaced byautorerunmaxtriesconfig option) – the only question is why this does not "kick in" when sending e-mail fails.
Is there any way to fix this and make Event trigger repeat attempts to send e-mails when they are unsuccessful? Or at least properly report them? Can I help in any way?
- Ngôn ngữ chính
- PHP
- Star
- 46
- Fork
- 29
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của catalyst/moodle-tool_trigger
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
catalyst/moodle-tool_trigger#253 ·
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 45/100
catalyst/moodle-tool_trigger#251 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
catalyst/moodle-tool_trigger#249 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
catalyst/moodle-tool_trigger#248 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
catalyst/moodle-tool_trigger#243 ·
Tất cả issue của catalyst/moodle-tool_trigger
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
taskforcesh/bullmq#5238 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itCó thể đã có người làm @bfs2021 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Automattic/jetpack#55517 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
-
area/import type/enhancement when/later
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày