No Mails from Moodle - PHP Error in Cron / Scheduled Task for sending E-Mails
-
@d-sein said in No Mails from Moodle - PHP Error in Cron / Scheduled Task for sending E-Mails:
Hello,
this is my first post here at the cloudron forum with the need of any helping input for fixing this (big) problem...
On 2 instances (VM's) with cloudron and the moodle app we have the problem that e-mails from forums and maybe other activities are not send.
Outgoing E-Mails (SMTP) are ok and tested. Also ok and tested are direct (mass-)messages from a course to enrolled users as e-mails.
It seems that the cron can not be completed while running / idle scheduled tasks.
In both instances found the following PHP Error in the scheduled task "core\task\messaging_cleanup_task"
Have the same error.
-
Debugging this now.. I can run the cron jobs manually just fine:
root@e13267b5-4d35-4443-9990-39dcae50884e:/app/code/new# /usr/local/bin/gosu www-data:www-data /usr/bin/php /app/code/new/admin/cli/cron.php Server Time: Sat, 20 Aug 2022 15:13:01 +0100 Execute scheduled task: Background processing for messaging (core\task\messaging_cleanup_task) ... started 15:13:01. Current memory use 15.8 MB.
-
@d-sein @jagan can you add a line in
/app/data/moodle/config.php
:$CFG->dirroot = '/app/data/moodle';
That seems to fix the problem.
root@e13267b5-4d35-4443-9990-39dcae50884e:/app/data/moodle# php ./admin/tool/task/cli/schedule_task.php --execute="\core\task\messaging_clea nup_task" Execute scheduled task: Background processing for messaging (core\task\messaging_cleanup_task) ... used 8 dbqueries ... used 0.016392946243286 seconds
-
@girish Thanks for investigating...
PHP Error fixed, but Problem with sending mails from forums or the daily digest mails not solved.
Automatic updates are enabled and saw that the "missing" line in
/app/data/moodle/config.php
was already set.Cloudron Version: v7.2.5 (Ubuntu 20.04.2 LTS)
Moodle App Version: 4.0.3I can confirm that the PHP Error is fixed and the cron task
core\task\messaging_cleanup_task
works,
BUT still no mails from forums (new threads, posts or daily digest) going out to users.root@xxxxxxxx:/app/data/moodle# php ./admin/tool/task/cli/schedule_task.php --execute="\core\task\messaging_cleanup_task" Execute scheduled task: Hintergrundprozess für Mitteilungen (core\task\messaging_cleanup_task) ... used 8 dbqueries ... used 0.029027938842773 seconds
Double checked configs of mail within moodle and cloudron (E-Mail Log) today. Other mails like "forget password", mails from direct messaging and testmails are send to users.
Could anyone here please confirm that mails like daily digest mails or forum mails are working with moodle app within cloudron?
With debugging enabled i have now following errors/warning by executing the
adhoc_task.php
in the CLI:php adhoc_task.php --execute -f Server Time: Tue, 23 Aug 2022 12:10:27 +0200 Execute adhoc task: mod_forum\task\send_user_notifications ... started 12:10:28. Current memory use 12.8 MB. Sending messages to xxxxx-moodle (2) PHP Notice: Undefined property: stdClass::$mnet_localhost_id in /app/data/moodle/lib/accesslib.php on line 1814 Notice: Undefined property: stdClass::$mnet_localhost_id in /app/data/moodle/lib/accesslib.php on line 1814 PHP Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 PHP Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 PHP Notice: Undefined property: stdClass::$mnet_localhost_id in /app/data/moodle/lib/accesslib.php on line 1814 Notice: Undefined property: stdClass::$mnet_localhost_id in /app/data/moodle/lib/accesslib.php on line 1814 PHP Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 PHP Notice: Undefined property: stdClass::$mnet_localhost_id in /app/data/moodle/lib/accesslib.php on line 1814 Notice: Undefined property: stdClass::$mnet_localhost_id in /app/data/moodle/lib/accesslib.php on line 1814 PHP Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 PHP Notice: Undefined property: stdClass::$libdir in /app/data/moodle/lib/weblib.php on line 1111 Notice: Undefined property: stdClass::$libdir in /app/data/moodle/lib/weblib.php on line 1111 PHP Warning: require_once(/phpmailer/moodle_phpmailer.php): failed to open stream: No such file or directory in /app/data/moodle/lib/weblib.php on line 1111 Warning: require_once(/phpmailer/moodle_phpmailer.php): failed to open stream: No such file or directory in /app/data/moodle/lib/weblib.php on line 1111 PHP Fatal error: require_once(): Failed opening required '/phpmailer/moodle_phpmailer.php' (include_path='/app/data/moodle/lib/pear:.:/usr/share/php') in /app/data/moodle/lib/weblib.php on line 1111 Fatal error: require_once(): Failed opening required '/phpmailer/moodle_phpmailer.php' (include_path='/app/data/moodle/lib/pear:.:/usr/share/php') in /app/data/moodle/lib/weblib.php on line 1111 PHP Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 PHP Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100 Notice: Undefined property: stdClass::$debugdeveloper in /app/data/moodle/lib/dml/moodle_database.php on line 1100
Here are some links from moodle forums with nearly the same problem:
https://moodle.org/mod/forum/discuss.php?d=436778
https://moodle.org/mod/forum/discuss.php?d=395394
https://moodle.org/mod/forum/discuss.php?d=388490
https://moodle.org/mod/forum/discuss.php?d=397915 -
@girish Thanks for your reply. Yesterday i installed a complete new moodle app version.
Today i tested a lot, but also the settings from the post https://moodle.org/mod/forum/discuss.php?d=388490 didn't solve the problem and several other attempts.
But it works now after disabling / unchecking the settings "Cron execution via command line only"
moodle -> site administration -> security
and allow running the cron from a web browser the forum mails are send out. No errors and no entries in the db -> table mdl_task_adhocPlease explain me the difference of the build in cli cronjob within cloudron / moodle and the webbased moodle cron?
Or cloud you please advise me what settings i should use for the cli cron.
Otherwise i think of creating and using a new cronjob with
***** /usr/bin/wget https://{your-domain}/admin/cron.php?password=ganzgeheim
Thanks a lot.
Webbased Cron:
https://{your-domain}/admin/cron.php?password=ganzgeheimWebbrowser Cron / Result: Cron script completed correctly
Server Time: Wed, 24 Aug 2022 15:00:05 +0200 Execute scheduled task: Unbestätigte Nutzerprofile löschen (core\task\delete_unconfirmed_users_task) ... started 15:00:05. Current memory use 2.7 MB. ... used 3 dbqueries ... used 0.0016529560089111 seconds Scheduled task complete: Unbestätigte Nutzerprofile löschen (core\task\delete_unconfirmed_users_task) Execute scheduled task: Indizierung für die globale Suche (core\task\search_index_task) ... started 15:00:05. Current memory use 3.2 MB. ... used 0 dbqueries ... used 0.00017499923706055 seconds Scheduled task complete: Indizierung für die globale Suche (core\task\search_index_task) Execute scheduled task: Papierkorb für den Kurs aufräumen (tool_recyclebin\task\cleanup_course_bin) ... started 15:00:05. Current memory use 2.8 MB. ... used 3 dbqueries ... used 0.0016279220581055 seconds Scheduled task complete: Papierkorb für den Kurs aufräumen (tool_recyclebin\task\cleanup_course_bin) Execute scheduled task: Papierkorb für den Kursbereich aufräumen (tool_recyclebin\task\cleanup_category_bin) ... started 15:00:05. Current memory use 2.8 MB. ... used 3 dbqueries ... used 0.0025839805603027 seconds Scheduled task complete: Papierkorb für den Kursbereich aufräumen (tool_recyclebin\task\cleanup_category_bin) Execute scheduled task: E-Mail-Versand aus Foren (mod_forum\task\cron_task) ... started 15:00:05. Current memory use 2.9 MB. Removing old digest records from 7 days ago. Removed all old digest records. Fetching unmailed posts. No posts found. ... used 2 dbqueries ... used 0.0037319660186768 seconds Scheduled task complete: E-Mail-Versand aus Foren (mod_forum\task\cron_task) Execute scheduled task: Abgaben für Anmerkungen vorbereiten (assignfeedback_editpdf\task\convert_submissions) ... started 15:00:05. Current memory use 3.0 MB. ... used 1 dbqueries ... used 0.0014200210571289 seconds Scheduled task complete: Abgaben für Anmerkungen vorbereiten (assignfeedback_editpdf\task\convert_submissions) Execute scheduled task: Manuelle Einschreibung synchronisieren (enrol_manual\task\sync_enrolments) ... started 15:00:05. Current memory use 3.3 MB. Verifying manual enrolment expiration... ...manual enrolment updates finished. ... used 0 dbqueries ... used 0.00061392784118652 seconds Scheduled task complete: Manuelle Einschreibung synchronisieren (enrol_manual\task\sync_enrolments) Execute scheduled task: Systemnachricht zum Ablauf von manuellen Einschreibungen (enrol_manual\task\send_expiry_notifications) ... started 15:00:05. Current memory use 3.3 MB. manual enrolment expiry notifications were already sent today at Mittwoch, 24. August 2022, 06:00. ... used 0 dbqueries ... used 0.00040388107299805 seconds Scheduled task complete: Systemnachricht zum Ablauf von manuellen Einschreibungen (enrol_manual\task\send_expiry_notifications) Execute scheduled task: Selbsteinschreibung synchronisieren (enrol_self\task\sync_enrolments) ... started 15:00:05. Current memory use 3.3 MB. Verifying self-enrolments... ...user self-enrolment updates finished. No expired enrol_self enrolments detected ... used 6 dbqueries ... used 0.0055639743804932 seconds Scheduled task complete: Selbsteinschreibung synchronisieren (enrol_self\task\sync_enrolments) Execute scheduled task: Systemnachricht zum Ablauf von Selbsteinschreibungen (enrol_self\task\send_expiry_notifications) ... started 15:00:05. Current memory use 3.3 MB. self enrolment expiry notifications were already sent today at Mittwoch, 24. August 2022, 06:00. ... used 0 dbqueries ... used 0.00037312507629395 seconds Scheduled task complete: Systemnachricht zum Ablauf von Selbsteinschreibungen (enrol_self\task\send_expiry_notifications) Execute scheduled task: Badges verleihen (core\task\badges_cron_task) ... started 15:00:05. Current memory use 3.6 MB. Started reviewing available badges. Badges were issued 0 time(s). ... used 1 dbqueries ... used 0.0018401145935059 seconds Scheduled task complete: Badges verleihen (core\task\badges_cron_task) Execute scheduled task: Hintergrundprozess für Badge-Mitteilungen (core\task\badges_message_task) ... started 15:00:05. Current memory use 3.6 MB. Sending scheduled badge notifications. ... used 1 dbqueries ... used 0.0011579990386963 seconds Scheduled task complete: Hintergrundprozess für Badge-Mitteilungen (core\task\badges_message_task) Execute scheduled task: Hintergrundprozess für das Chatmodul (mod_chat\task\cron_task) ... started 15:00:05. Current memory use 3.6 MB. ... used 4 dbqueries ... used 0.0040950775146484 seconds Scheduled task complete: Hintergrundprozess für das Chatmodul (mod_chat\task\cron_task) Execute scheduled task: Hintergrundprozess für Lernpakete (mod_scorm\task\cron_task) ... started 15:00:05. Current memory use 3.7 MB. ... used 0 dbqueries ... used 0.00040388107299805 seconds Scheduled task complete: Hintergrundprozess für Lernpakete (mod_scorm\task\cron_task) Execute scheduled task: Barrierefreiheitsprüfung mit Bulk-Caching verarbeiten (tool_brickfield\task\bulk_process_courses) ... started 15:00:05. Current memory use 3.8 MB. ... used 3 dbqueries ... used 0.0026500225067139 seconds Scheduled task complete: Barrierefreiheitsprüfung mit Bulk-Caching verarbeiten (tool_brickfield\task\bulk_process_courses) Execute scheduled task: Bulk-Caching verarbeiten (tool_brickfield\task\bulk_process_caches) ... started 15:00:05. Current memory use 3.8 MB. ... used 3 dbqueries ... used 0.0022859573364258 seconds Scheduled task complete: Bulk-Caching verarbeiten (tool_brickfield\task\bulk_process_caches) Execute scheduled task: Inhaltsanalyseanforderungen verarbeiten (tool_brickfield\task\process_analysis_requests) ... started 15:00:05. Current memory use 3.8 MB. ... used 3 dbqueries ... used 0.0025320053100586 seconds Scheduled task complete: Inhaltsanalyseanforderungen verarbeiten (tool_brickfield\task\process_analysis_requests) Execute scheduled task: Alte Sessions bereinigen (core\task\session_cleanup_task) ... started 15:00:05. Current memory use 3.8 MB. ... used 24 dbqueries ... used 0.014279127120972 seconds Scheduled task complete: Alte Sessions bereinigen (core\task\session_cleanup_task) Execute scheduled task: Neues Nutzerkennwort senden (core\task\send_new_user_passwords_task) ... started 15:00:05. Current memory use 4.2 MB. ... used 1 dbqueries ... used 0.0011022090911865 seconds Scheduled task complete: Neues Nutzerkennwort senden (core\task\send_new_user_passwords_task) Execute scheduled task: Systemnachricht zu fehlgeschlagenen Anmeldeversuchen senden (core\task\send_failed_login_notifications_task) ... started 15:00:05. Current memory use 4.2 MB. ... used 2 dbqueries ... used 0.0026299953460693 seconds Scheduled task complete: Systemnachricht zu fehlgeschlagenen Anmeldeversuchen senden (core\task\send_failed_login_notifications_task) Execute scheduled task: Legacy Cron für Plugins (core\task\legacy_plugin_cron_task) ... started 15:00:05. Current memory use 4.2 MB. Running auth crons if required... Running enrol crons if required... Starting activity modules Finished activity modules Starting blocks Finished blocks Starting admin reports Finished admin reports Starting course reports Finished course reports Starting gradebook plugins Finished gradebook plugins ... used 2 dbqueries ... used 0.004518985748291 seconds Scheduled task complete: Legacy Cron für Plugins (core\task\legacy_plugin_cron_task) Execute scheduled task: Hintergrundprozess für Bewertungen (core\task\grade_cron_task) ... started 15:00:05. Current memory use 4.3 MB. ... used 6 dbqueries ... used 0.0050089359283447 seconds Scheduled task complete: Hintergrundprozess für Bewertungen (core\task\grade_cron_task) Execute scheduled task: Normale Abschlussdaten berechnen (core\task\completion_regular_task) ... started 15:00:05. Current memory use 4.3 MB. Aggregating completions ... used 18 dbqueries ... used 0.033792972564697 seconds Scheduled task complete: Normale Abschlussdaten berechnen (core\task\completion_regular_task) Execute scheduled task: Hintergrundprozess für Portfolio-Plugins (core\task\portfolio_cron_task) ... started 15:00:05. Current memory use 4.3 MB. ... used 0 dbqueries ... used 0.00014495849609375 seconds Scheduled task complete: Hintergrundprozess für Portfolio-Plugins (core\task\portfolio_cron_task) Execute scheduled task: Hintergrundprozess für den Legacy Cron in Plagiat-Plugins (core\task\plagiarism_cron_task) ... started 15:00:05. Current memory use 4.3 MB. ... used 0 dbqueries ... used 0.00014781951904297 seconds Scheduled task complete: Hintergrundprozess für den Legacy Cron in Plagiat-Plugins (core\task\plagiarism_cron_task) Execute scheduled task: Systemnachrichten zu Kalendereinträgen senden (core\task\calendar_cron_task) ... started 15:00:05. Current memory use 4.3 MB. ... used 1 dbqueries ... used 0.001370906829834 seconds Scheduled task complete: Systemnachrichten zu Kalendereinträgen senden (core\task\calendar_cron_task) Execute scheduled task: Externe Blogs synchronisieren (core\task\blog_cron_task) ... started 15:00:05. Current memory use 4.5 MB. ... used 2 dbqueries ... used 0.0016438961029053 seconds Scheduled task complete: Externe Blogs synchronisieren (core\task\blog_cron_task) Execute scheduled task: Hintergrundprozess um Fragen-Vorschauen zu löschen (core\task\question_preview_cleanup_task) ... started 15:00:05. Current memory use 4.5 MB. Cleaning up old question previews...done. ... used 5 dbqueries ... used 0.0082058906555176 seconds Scheduled task complete: Hintergrundprozess um Fragen-Vorschauen zu löschen (core\task\question_preview_cleanup_task) Execute scheduled task: Hintergrundprozess zum Löschen von Fragestatistik-Caches (core\task\question_stats_cleanup_task) ... started 15:00:05. Current memory use 4.7 MB. Cleaning up old question statistics cache records...done. ... used 4 dbqueries ... used 0.0024378299713135 seconds Scheduled task complete: Hintergrundprozess zum Löschen von Fragestatistik-Caches (core\task\question_stats_cleanup_task) Execute scheduled task: Berichtszeitpläne senden (core_reportbuilder\task\send_schedules) ... started 15:00:05. Current memory use 4.7 MB. ... used 1 dbqueries ... used 0.0012600421905518 seconds Scheduled task complete: Berichtszeitpläne senden (core_reportbuilder\task\send_schedules) Execute scheduled task: Hintergrundprozess für das Aufgabenmodul (mod_assign\task\cron_task) ... started 15:00:05. Current memory use 4.8 MB. ... used 3 dbqueries ... used 0.012731075286865 seconds Scheduled task complete: Hintergrundprozess für das Aufgabenmodul (mod_assign\task\cron_task) Execute scheduled task: Aktualisierung überfälliger Testversuche (mod_quiz\task\update_overdue_attempts) ... started 15:00:05. Current memory use 5.0 MB. Looking for quiz overdue quiz attempts... Considered 0 attempts in 0 quizzes. ... used 3 dbqueries ... used 0.0089221000671387 seconds Scheduled task complete: Aktualisierung überfälliger Testversuche (mod_quiz\task\update_overdue_attempts) Execute scheduled task: Testberichte Cron Job (veraltet) (mod_quiz\task\legacy_quiz_reports_cron) ... started 15:00:05. Current memory use 5.1 MB. ... used 0 dbqueries ... used 0.00022006034851074 seconds Scheduled task complete: Testberichte Cron Job (veraltet) (mod_quiz\task\legacy_quiz_reports_cron) Execute scheduled task: Testzugriffsregeln Cron Job (veraltet) (mod_quiz\task\legacy_quiz_accessrules_cron) ... started 15:00:06. Current memory use 5.1 MB. ... used 0 dbqueries ... used 0.00029420852661133 seconds Scheduled task complete: Testzugriffsregeln Cron Job (veraltet) (mod_quiz\task\legacy_quiz_accessrules_cron) Execute scheduled task: Hintergrundprozess für gegenseitige Beurteilung (mod_workshop\task\cron_task) ... started 15:00:06. Current memory use 5.1 MB. processing workshop subplugins ... ... used 1 dbqueries ... used 0.001568078994751 seconds Scheduled task complete: Hintergrundprozess für gegenseitige Beurteilung (mod_workshop\task\cron_task) Execute scheduled task: Alte Cron-Zuteilung für gegenseitige Beurteilungen (mod_workshop\task\legacy_workshop_allocation_cron) ... started 15:00:06. Current memory use 5.1 MB. ... used 0 dbqueries ... used 0.00019311904907227 seconds Scheduled task complete: Alte Cron-Zuteilung für gegenseitige Beurteilungen (mod_workshop\task\legacy_workshop_allocation_cron) Execute scheduled task: Eingehende E-Mail-Abholung (tool_messageinbound\task\pickup_task) ... started 15:00:06. Current memory use 5.2 MB. Inbound Message not fully configured - exiting early. ... used 0 dbqueries ... used 0.00025796890258789 seconds Scheduled task complete: Eingehende E-Mail-Abholung (tool_messageinbound\task\pickup_task) Execute scheduled task: Event-Monitor-Einträge löschen (tool_monitor\task\clean_events) ... started 15:00:06. Current memory use 5.1 MB. ... used 0 dbqueries ... used 0.00025200843811035 seconds Scheduled task complete: Event-Monitor-Einträge löschen (tool_monitor\task\clean_events) Execute scheduled task: Hintergrundprozess für die geplante Zuordnung (workshopallocation_scheduled\task\cron_task) ... started 15:00:06. Current memory use 5.2 MB. ... no workshops awaiting scheduled allocation. ... used 1 dbqueries ... used 0.0013461112976074 seconds Scheduled task complete: Hintergrundprozess für die geplante Zuordnung (workshopallocation_scheduled\task\cron_task) Ran 0 adhoc tasks found at Wed, 24 Aug 2022 15:00:05 +0200 Cron script completed correctly Cron completed at 15:00:06. Memory used 5.2 MB. Execution took 0.847156 seconds
-
I am having a similar problem with Moodle (4.1.2) and forum emails not being sending, but unfortunately the solution to allow cron via browser hasn't worked for me and I am still getting the error
Failed opening required '/phpmailer/moodle_phpmailer.php'
.Any other suggestions?
-
@ccfu said in No Mails from Moodle - PHP Error in Cron / Scheduled Task for sending E-Mails:
but unfortunately the solution to allow cron via browser hasn't worked for me
This shouldn't be required. The package already runs cron. can you run
/usr/local/bin/gosu www-data:www-data /usr/bin/php /app/code/new/admin/cli/cron.php
? -
@girish said in No Mails from Moodle - PHP Error in Cron / Scheduled Task for sending E-Mails:
@ccfu can you check if you installation has that value set?
Yes, it does.
@girish said in No Mails from Moodle - PHP Error in Cron / Scheduled Task for sending E-Mails:
@ccfu said in No Mails from Moodle - PHP Error in Cron / Scheduled Task for sending E-Mails:
but unfortunately the solution to allow cron via browser hasn't worked for me
This shouldn't be required. The package already runs cron. can you run
/usr/local/bin/gosu www-data:www-data /usr/bin/php /app/code/new/admin/cli/cron.php
?Yes, that runs and completes successfully. There are also several other tasks completing regularly without issue.
The error I am getting at
/admin/tasklogs.php
is:Execute adhoc task: mod_forum\task\send_user_notifications Adhoc task id: 32 Adhoc task custom data: ["1"] ... started 21:14:29. Current memory use 31.7 MB. Debugging increased temporarily due to faildelay of 86400 Sending messages to xxx (username removed) ... used 53 dbqueries ... used 0.32096004486084 seconds Adhoc task failed: mod_forum\task\send_user_notifications,Failed opening required '/phpmailer/moodle_phpmailer.php' (include_path='/app/data/moodle/lib/pear:.:/usr/share/php')
-
I'd guess the update that happened last night is why I received an email around 3am this morning saying there was a new login to my account on 12 May 2022
-
I made sure to remove the queued adhoc tasks before updating to prevent that from happening and users receiving notifications of past events. At least you now know that adhoc tasks are working again in your installation
-
@ccfu said in No Mails from Moodle - PHP Error in Cron / Scheduled Task for sending E-Mails:
I made sure to remove the queued adhoc tasks before updating to prevent that from happening and users receiving notifications of past events. At least you now know that adhoc tasks are working again in your installation
Thankfully in my case I don't yet actually have any users. I just installed to have a play around (because I do have plans to run some online courses) and haven't even really got around to doing that yet