Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-70046

If mail server connection fails forum notification task does not fail

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.8.5
    • 4.0
    • Forum, Messages
    • MOODLE_38_STABLE
    • MOODLE_400_STABLE
    • MDL-70046-master-notificationfailure
    • Hide

      You will need Moodle to be configured to send e-mails via a mailhog server that you can control.

      Manual Test 1 - No Digest - Complete Failure

      1. Ensure mailhog is stopped
      2. Set up a forum with at least one user subscribed to it
      3. Verify user Email Digest type is set to 'No Digest'
      4. Add a post to the form (use Advanced editing and ensure that Send forum post notifications with no editing-time delay is checked for the post)
      5. Run the Forum mailings and maintenance jobs scheduled task
      6. Run the CRON
      7. Review the task log and confirm \mod_forum\task\send_user_notifications task now recorded as a FAIL
      8. Review the task log and confirm message recorded as failed

      Manual Test 2 - No Digest - Partial Failure

      This is a bit awkward to test, you will likely want XDEBUG installed with a breakpoint just before posts are sent in mod/forum/classes/task/send_user_notifications.php (line 155) and have debugging enabled when CRON is run

      1. Ensure mailhog is stopped
      2. Set up a forum with multiple discussions
      3. with at least one user subscribed to it
      4. Verify user Email Digest type is set to 'No Digest'
      5. Add a post to each of the discussions in the forum (use Advanced editing and ensure that Send forum post notifications with no editing-time delay is checked for the posts)
      6. Run the Forum mailings and maintenance jobs scheduled task
      7. Run the CRON
      8. Ensure mailhog is started again after the first send_user_notifications task fails
      9. Review the task log and confirm \mod_forum\task\send_user_notifications task now recorded as a SUCCESS
      10. Review the task log and confirm the first message is recorded as posted and subsequent messages recorded as failed i.e.

          Failed to send post 60
          Post 61 sent
        Sent 1 messages with 1 failures
        

      11. Wait 5 mins then re run the CRON
      12. Review the task log and confirm \mod_forum\task\send_user_notifications task now recorded as a SUCCESS
      13. Review the task log and confirm the previsouly failed message is recorded as posted

      Manual Test 3 - Digest

      1. Ensure mailhog is stopped
      2. Set up a forum with at least one user subscribed to it
      3. Verify user Email Digest type is set to 'Complete' / 'Subjects'
      4. Add a post to the form (use Advanced editing and ensure that Send forum post notifications with no editing-time delay is checked for the post)
      5. Run the Forum mailings and maintenance jobs scheduled task
      6. Run the CRON
      7. Review the task log and confirm \mod_forum\task\send_user_digests task now recorded as a FAIL
      8. Review the task log and confirm message recorded as failed
      Show
      You will need Moodle to be configured to send e-mails via a mailhog server that you can control. Manual Test 1 - No Digest - Complete Failure Ensure mailhog is stopped Set up a forum with at least one user subscribed to it Verify user Email Digest type is set to 'No Digest' Add a post to the form (use Advanced editing and ensure that Send forum post notifications with no editing-time delay is checked for the post) Run the Forum mailings and maintenance jobs scheduled task Run the CRON Review the task log and confirm \mod_forum\task\send_user_notifications task now recorded as a FAIL Review the task log and confirm message recorded as failed Manual Test 2 - No Digest - Partial Failure This is a bit awkward to test, you will likely want XDEBUG installed with a breakpoint just before posts are sent in mod/forum/classes/task/send_user_notifications.php (line 155) and have debugging enabled when CRON is run Ensure mailhog is stopped Set up a forum with multiple discussions with at least one user subscribed to it Verify user Email Digest type is set to 'No Digest' Add a post to each of the discussions in the forum (use Advanced editing and ensure that Send forum post notifications with no editing-time delay is checked for the posts) Run the Forum mailings and maintenance jobs scheduled task Run the CRON Ensure mailhog is started again after the first send_user_notifications task fails Review the task log and confirm \mod_forum\task\send_user_notifications task now recorded as a SUCCESS Review the task log and confirm the first message is recorded as posted and subsequent messages recorded as failed i.e. Failed to send post 60 Post 61 sent Sent 1 messages with 1 failures Wait 5 mins then re run the CRON Review the task log and confirm \mod_forum\task\send_user_notifications task now recorded as a SUCCESS Review the task log and confirm the previsouly failed message is recorded as posted Manual Test 3 - Digest Ensure mailhog is stopped Set up a forum with at least one user subscribed to it Verify user Email Digest type is set to 'Complete' / 'Subjects' Add a post to the form (use Advanced editing and ensure that Send forum post notifications with no editing-time delay is checked for the post) Run the Forum mailings and maintenance jobs scheduled task Run the CRON Review the task log and confirm \mod_forum\task\send_user_digests task now recorded as a FAIL Review the task log and confirm message recorded as failed

    Description

      We have found that some of our forum e-mails have not sent, because there was a temporary problem connecting to the e-mail server, but the task for sending the mail completed as though it was a success. This means that some of our users were never getting forum e-mails (and we did not know until the complained since we did not have failed task logs).

      Sample of a CRON log entry (with redacted user details):

      Sending messages to username (123456)
      Error: lib/moodlelib.php email_to_user(): SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
      Post 1180546 sent
      Sent 1 messages with 0 failures
      

      It seems to me that in a case like this the task should fail, so that it can be retried later.

      Attachments

        Issue Links

          Activity

            People

              joseph.baxter Joseph Baxter
              nmagill Neill Magill
              Neill Magill Neill Magill
              Adrian Greeve Adrian Greeve
              Sujith Haridasan Sujith Haridasan
              Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                19/Apr/22

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours
                  4h