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

Connection to SMTP mail not working with Moodle 3.0 (result of phpmailer update)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.0 regressions, 3.0.1, 3.0.2
    • Fix Version/s: 3.0.3
    • Component/s: Messages
    • Testing Instructions:
      Hide

      (difficulty: easy, requires administrator access and access to an SMTP server supporting TLS, even if TLS is mis-configured i.e. not ready for production)

      1. Log in as an administrator
      2. Enable SMTP debugging or install https://moodle.org/plugins/local_mailtest
      3. Configure SMTP settings to use the SMTP server above w/o requiring TLS i.e. do not leave smtphosts empty and set smtpsecure to None
      4. Send a test email and look at the debug output. It should tell you about the TLS being available e.g.:

                                                 250-SIZE 52428800
                                                 250-8BITMIME
                                                 250-PIPELINING
                                                 250-AUTH PLAIN LOGIN
                                            -->  250-STARTTLS <--
                                                 250 HELP
        

        but you should not read about the client asking for TLS i.e. the debug output is missing:

        YYYY-MM-DD hh:mm:ss    CLIENT -> SERVER: STARTTLS
        

      Show
      (difficulty: easy, requires administrator access and access to an SMTP server supporting TLS, even if TLS is mis-configured i.e. not ready for production) Log in as an administrator Enable SMTP debugging or install https://moodle.org/plugins/local_mailtest Configure SMTP settings to use the SMTP server above w/o requiring TLS i.e. do not leave smtphosts empty and set smtpsecure to None Send a test email and look at the debug output. It should tell you about the TLS being available e.g.: 250-SIZE 52428800 250-8BITMIME 250-PIPELINING 250-AUTH PLAIN LOGIN --> 250-STARTTLS <-- 250 HELP but you should not read about the client asking for TLS i.e. the debug output is missing: YYYY-MM-DD hh:mm:ss CLIENT -> SERVER: STARTTLS
    • Workaround:
      Hide

      I rolled the version of PHPmailer back to 5.2.7, and it seems to have resolved the issue.

      Show
      I rolled the version of PHPmailer back to 5.2.7, and it seems to have resolved the issue.
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE
    • Pull from Repository:
    • Pull 3.0 Branch:
      m30_MDL-52637_Disable_Automatically_Enabling_TLS_Encryption
    • Pull Master Branch:
      m31_MDL-52637_Disable_Automatically_Enabling_TLS_Encryption

      Description

      SMTP connection for forgotten passwords and new user confirmations is no longer working since updating to Moodle 3.0 from 2.0.x. I have tried all the various settings for SMTP authorization type (as well as changing other settings) on the plugins - message outputs - email page, and consistently either get an error message or fail to trigger an email when testing for forgotten passwords, etc.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              marina Marina Glancy added a comment -

              Hello, please search for existing issues in the tracker, this is most likely related to phpmailer configuration, see https://tracker.moodle.org/issues/?jql=project%20%3D%20MDL%20AND%20resolution%20%3D%20Unresolved%20AND%20text%20~%20phpmailer

              Show
              marina Marina Glancy added a comment - Hello, please search for existing issues in the tracker, this is most likely related to phpmailer configuration, see https://tracker.moodle.org/issues/?jql=project%20%3D%20MDL%20AND%20resolution%20%3D%20Unresolved%20AND%20text%20~%20phpmailer
              Hide
              marina Marina Glancy added a comment -

              There are at least three similar issues: MDL-43947, MDL-43633, MDL-43667
              Nobody yet was able to provide exact replication instructions and/or patch, this seems to be related to the latest release of phpmail, the workaround is to replace the phpmailer with the older version.

              I'm going to close this issue as a duplicate, please follow/vote/comment on the above-mentioned issues.

              Show
              marina Marina Glancy added a comment - There are at least three similar issues: MDL-43947 , MDL-43633 , MDL-43667 Nobody yet was able to provide exact replication instructions and/or patch, this seems to be related to the latest release of phpmail, the workaround is to replace the phpmailer with the older version. I'm going to close this issue as a duplicate, please follow/vote/comment on the above-mentioned issues.
              Hide
              matteo Matteo Scaramuccia added a comment -

              Hi Marina Glancy,
              people from the Community is talking about a regression: https://moodle.org/mod/forum/discuss.php?d=324719#p1308606 => https://github.com/PHPMailer/PHPMailer/commit/9da56fc1328a72aa124b35b738966315c41ef5c6#diff-ace81e501931d8763b49f2410cf3094dR1370.

              The whole thread makes sense to me - though I didn't try to replicate it by myself, besides PHPMailer could be updated to 5.2.14 (see its changelog). It looks like we should set to $SMTPAutoTLS to false in the moodle helper. I'll post some details in that thread.

              Show
              matteo Matteo Scaramuccia added a comment - Hi Marina Glancy , people from the Community is talking about a regression: https://moodle.org/mod/forum/discuss.php?d=324719#p1308606 => https://github.com/PHPMailer/PHPMailer/commit/9da56fc1328a72aa124b35b738966315c41ef5c6#diff-ace81e501931d8763b49f2410cf3094dR1370 . The whole thread makes sense to me - though I didn't try to replicate it by myself, besides PHPMailer could be updated to 5.2.14 (see its changelog ). It looks like we should set to $SMTPAutoTLS to false in the moodle helper. I'll post some details in that thread.
              Hide
              marina Marina Glancy added a comment -

              oh, are you saying it's another phpmailer bug and not related to MDL-43947 ?
              I found this issue in phpmailer: https://github.com/PHPMailer/PHPMailer/issues/387

              I'll reopen this issue then

              Show
              marina Marina Glancy added a comment - oh, are you saying it's another phpmailer bug and not related to MDL-43947 ? I found this issue in phpmailer: https://github.com/PHPMailer/PHPMailer/issues/387 I'll reopen this issue then
              Hide
              cameron1729 Cameron Ball added a comment - - edited

              I'm unable to make it fail :[ sending a forgotten password email using both SSL and TLS on a clean install. No problem.

              Seems like there must be some extra jazz going on somewhere.

              Show
              cameron1729 Cameron Ball added a comment - - edited I'm unable to make it fail :[ sending a forgotten password email using both SSL and TLS on a clean install. No problem. Seems like there must be some extra jazz going on somewhere.
              Hide
              marina Marina Glancy added a comment -

              this must have something to do with the particular smtp server(s)

              Show
              marina Marina Glancy added a comment - this must have something to do with the particular smtp server(s)
              Hide
              matteo Matteo Scaramuccia added a comment -

              Hi Marina,
              will test in the next evenings with Postfix using a default configuration (I'll ask for configuration details even in the Community thread): IMHO at least the new behaviour should be set to false, regardless being the root cause for the mail issue.

              Show
              matteo Matteo Scaramuccia added a comment - Hi Marina, will test in the next evenings with Postfix using a default configuration (I'll ask for configuration details even in the Community thread): IMHO at least the new behaviour should be set to false , regardless being the root cause for the mail issue.
              Hide
              matteo Matteo Scaramuccia added a comment -

              Hi Cameron Ball
              please, mis-configure the TLS support in your SMTP server: Moodle will try to use it regardless you want to use it due to https://github.com/PHPMailer/PHPMailer/commit/9da56fc1328a72aa124b35b738966315c41ef5c6#diff-ace81e501931d8763b49f2410cf3094dR1370.

              HTH,
              Matteo

              Show
              matteo Matteo Scaramuccia added a comment - Hi Cameron Ball please, mis-configure the TLS support in your SMTP server: Moodle will try to use it regardless you want to use it due to https://github.com/PHPMailer/PHPMailer/commit/9da56fc1328a72aa124b35b738966315c41ef5c6#diff-ace81e501931d8763b49f2410cf3094dR1370 . HTH, Matteo
              Show
              cibot CiBoT added a comment - Code verified against automated checks with warnings. Checked MDL-52637 using repository: https://github.com/scara/moodle MOODLE_30_STABLE (0 errors / 1 warnings) [branch: m30_MDL-52637_Disable_Automatically_Enabling_TLS_Encryption | CI Job ] phplint (0/0) , php (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/1) , grunt (0/0) , shifter (0/0) , master (0 errors / 1 warnings) [branch: m31_MDL-52637_Disable_Automatically_Enabling_TLS_Encryption | CI Job ] phplint (0/0) , php (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/1) , grunt (0/0) , shifter (0/0) , More information about this report
              Hide
              matteo Matteo Scaramuccia added a comment -

              Pinging Cameron Ball...

              TIA,
              Matteo

              Show
              matteo Matteo Scaramuccia added a comment - Pinging Cameron Ball ... TIA, Matteo
              Hide
              cameron1729 Cameron Ball added a comment -

              Hey Matteo, sorry for the delay in getting back to you. I agree with this change.

              Just one small thing. Would it be OK to change the comment above your change to reference this issue number? That way anyone looking at it can easily find this issue and see the discussion.

              Cheers : ]

              Show
              cameron1729 Cameron Ball added a comment - Hey Matteo, sorry for the delay in getting back to you. I agree with this change. Just one small thing. Would it be OK to change the comment above your change to reference this issue number? That way anyone looking at it can easily find this issue and see the discussion. Cheers : ]
              Hide
              matteo Matteo Scaramuccia added a comment -

              OK, will do my evening.

              Show
              matteo Matteo Scaramuccia added a comment - OK, will do my evening.
              Hide
              matteo Matteo Scaramuccia added a comment -

              Rebased and comment amended too, as requested.

              Show
              matteo Matteo Scaramuccia added a comment - Rebased and comment amended too, as requested.
              Hide
              matteo Matteo Scaramuccia added a comment -

              Submitting for integration...

              Show
              matteo Matteo Scaramuccia added a comment - Submitting for integration...
              Show
              cibot CiBoT added a comment - Code verified against automated checks with warnings. Checked MDL-52637 using repository: https://github.com/scara/moodle MOODLE_30_STABLE (0 errors / 1 warnings) [branch: m30_MDL-52637_Disable_Automatically_Enabling_TLS_Encryption | CI Job ] phplint (0/0) , php (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/1) , grunt (0/0) , shifter (0/0) , master (0 errors / 1 warnings) [branch: m31_MDL-52637_Disable_Automatically_Enabling_TLS_Encryption | CI Job ] phplint (0/0) , php (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/1) , grunt (0/0) , shifter (0/0) , More information about this report
              Hide
              dmonllao David Monllaó added a comment -

              The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

              TIA and ciao

              Show
              dmonllao David Monllaó added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
              Hide
              matteo Matteo Scaramuccia added a comment -

              Rebased.

              Show
              matteo Matteo Scaramuccia added a comment - Rebased.
              Hide
              cibot CiBoT added a comment -

              Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!

              Show
              cibot CiBoT added a comment - Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!
              Show
              cibot CiBoT added a comment - Code verified against automated checks with warnings. Checked MDL-52637 using repository: https://github.com/scara/moodle MOODLE_30_STABLE (0 errors / 1 warnings) [branch: m30_MDL-52637_Disable_Automatically_Enabling_TLS_Encryption | CI Job ] phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/1) , grunt (0/0) , shifter (0/0) , master (0 errors / 1 warnings) [branch: m31_MDL-52637_Disable_Automatically_Enabling_TLS_Encryption | CI Job ] phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/1) , grunt (0/0) , shifter (0/0) , More information about this report
              Hide
              dmonllao David Monllaó added a comment -

              Thanks Matteo, integrated to master and 30.

              Show
              dmonllao David Monllaó added a comment - Thanks Matteo, integrated to master and 30.
              Hide
              markn Mark Nelson added a comment -

              Hi -

              So, the mail server is set to use TLS but Moodle is set to use 'None'. With the patch this setting is not being overwritten (which is my understanding of what was happening before), so I do not see the message 'CLIENT -> SERVER: STARTTLS' but see the following, which seems correct -

              2016-02-10 06:30:50 SMTP Error: Could not authenticate.
              2016-02-10 06:30:50 CLIENT -> SERVER: QUIT

              Passing.

              Show
              markn Mark Nelson added a comment - Hi - So, the mail server is set to use TLS but Moodle is set to use 'None'. With the patch this setting is not being overwritten (which is my understanding of what was happening before), so I do not see the message 'CLIENT -> SERVER: STARTTLS' but see the following, which seems correct - 2016-02-10 06:30:50 SMTP Error: Could not authenticate. 2016-02-10 06:30:50 CLIENT -> SERVER: QUIT Passing.
              Hide
              dmonllao David Monllaó added a comment -

              Thanks for your patches, now they are part of Moodle and everybody is happy about it.

              Too much agreement kills a chat.
              – Eldridge Cleaver

              Show
              dmonllao David Monllaó added a comment - Thanks for your patches, now they are part of Moodle and everybody is happy about it. Too much agreement kills a chat. – Eldridge Cleaver
              Hide
              poltawski Dan Poltawski added a comment -

              Added qa_test_required to this issue as we should've caught this earlier.

              Show
              poltawski Dan Poltawski added a comment - Added qa_test_required to this issue as we should've caught this earlier.
              Hide
              matteo Matteo Scaramuccia added a comment -

              Just for internal QA reference, here is another way to break with PHPMailer and its new setting: https://github.com/PHPMailer/PHPMailer/issues/642 i.e. php70-openssl installed on FreeBSD but not configured.

              Show
              matteo Matteo Scaramuccia added a comment - Just for internal QA reference, here is another way to break with PHPMailer and its new setting: https://github.com/PHPMailer/PHPMailer/issues/642 i.e. php70-openssl installed on FreeBSD but not configured.
              Hide
              matteo Matteo Scaramuccia added a comment -

              Again, for internal QA reference: https://github.com/PHPMailer/PHPMailer/issues/643, PHP 5.6 changed its policy on accepting invalid certs i.e. the most common issue about an SMTP server where TLS has been enabled by default BUT w/o a valid certificate.

              Show
              matteo Matteo Scaramuccia added a comment - Again, for internal QA reference: https://github.com/PHPMailer/PHPMailer/issues/643 , PHP 5.6 changed its policy on accepting invalid certs i.e. the most common issue about an SMTP server where TLS has been enabled by default BUT w/o a valid certificate.
              Hide
              rajeshtaneja Rajesh Taneja added a comment -

              Thanks Dan and Matteo, MDLQA-9247 has been added to test this now.

              Show
              rajeshtaneja Rajesh Taneja added a comment - Thanks Dan and Matteo, MDLQA-9247 has been added to test this now.

                People

                • Votes:
                  2 Vote for this issue
                  Watchers:
                  11 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    14/Mar/16