Moodle
  1. Moodle
  2. MDL-30960

No option in email settings to speccify SSL or TLS (SMTPSecure property of PHPMailer)

    Details

    • Testing Instructions:
      Hide

      1. find a SMTP server that accepts TLS or SSL only
      2. specify the full SMTP hostname:port in Email settings, e.g.:smtp.example.com:587
      3. open up /login/forgot_password.php in browser and trigger a password reset email
      4. the cannotmailconfirm error show up

      Show
      1. find a SMTP server that accepts TLS or SSL only 2. specify the full SMTP hostname:port in Email settings, e.g.:smtp.example.com:587 3. open up /login/forgot_password.php in browser and trigger a password reset email 4. the cannotmailconfirm error show up
    • Workaround:
      Hide

      in moodle 2.2, editing get_mailer() function in /lib/moodlelib.php to add:
      $mailer->SMTPSecure = "tls"; // or "ssl";
      after $mailer->IsSMTP();

      Similar fixes can also be done directly in the /lib/PHPMailer files to force SSL/TLS.

      Show
      in moodle 2.2, editing get_mailer() function in /lib/moodlelib.php to add: $mailer->SMTPSecure = "tls"; // or "ssl"; after $mailer->IsSMTP(); Similar fixes can also be done directly in the /lib/PHPMailer files to force SSL/TLS.
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Rank:
      37362

      Description

      There is no option to specify the SMTPSecure property of PHPMailer in the admin email settings section. Specifying just the :port by itself is insufficient to trigger PHPMailer to use SSL/TLS connection prefix and will not initiate the connection correctly.

      If I remember correctly, this has been an issue since early 1.x (1.6?).

        Activity

        Hide
        Michael de Raadt added a comment -

        This option could be valuable. The specification of the mail server needs to be reviewed.

        Another workaround is to specify the protocol in the hostname of the server.

        Show
        Michael de Raadt added a comment - This option could be valuable. The specification of the mail server needs to be reviewed. Another workaround is to specify the protocol in the hostname of the server.
        Hide
        Shaun Maclean added a comment -

        Moodle 2.2.2+ (I suspect line numbers may change depending on precise build version)

        In order to use Office365 smtp for outbound moodle mails using workaround specified above:
        In Function get_mailer (line 4885 in my version)
        find line containing: $mailer->IsSMTP(); // use SMTP directly (line 4948 in my version)
        add a line below containing: $mailer->SMTPSecure = "tls"; (inserted at 4949 in my version)

        Adjust the following as appropriate for your office 365 account / moodle email account
        In plugins > message outputs > email
        SMTP hosts = pod12345.outlook.com:587
        SMTP username = yourmoodlenoreplyaccount@youremaildomain.as.appropriate
        SMTP password = yourmoodlenoreplyaccountpassword

        I also set the No-Reply address the same as the SMTP username

        note that specifying tls://pod12345.outlook.com:587 did not make it work, thus requiring the $mailer->SMTPSecure = "tls"; tweak.

        Show
        Shaun Maclean added a comment - Moodle 2.2.2+ (I suspect line numbers may change depending on precise build version) In order to use Office365 smtp for outbound moodle mails using workaround specified above: In Function get_mailer (line 4885 in my version) find line containing: $mailer->IsSMTP(); // use SMTP directly (line 4948 in my version) add a line below containing: $mailer->SMTPSecure = "tls"; (inserted at 4949 in my version) Adjust the following as appropriate for your office 365 account / moodle email account In plugins > message outputs > email SMTP hosts = pod12345.outlook.com:587 SMTP username = yourmoodlenoreplyaccount@youremaildomain.as.appropriate SMTP password = yourmoodlenoreplyaccountpassword I also set the No-Reply address the same as the SMTP username note that specifying tls://pod12345.outlook.com:587 did not make it work, thus requiring the $mailer->SMTPSecure = "tls"; tweak.
        Hide
        Andrew Davis added a comment -

        This issue was assigned to me automatically, however I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.

        For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

        Show
        Andrew Davis added a comment - This issue was assigned to me automatically, however I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

          People

          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: