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

Several core emails provide only text format

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Prerequisites

      1. Set-up mailcatcher (https://mailcatcher.me/).
      2. Log in as an admin.
      3. Visit ‘Site administration’ > ‘Server’ > ‘Outgoing mail configuration’.
      4. Set the 'SMTP hosts' field to '127.0.0.1:1025'.
      5. Save.
      6. An active account at https://backpack.openbadges.org

      Testing

      1. As site admin go to Site administration > Language > Language Customisation
      2. Choose English and Open language pack for editing
      3. Edit 'newusernewpasswordtext', 'emailconfirmation', 'emailresetconfirmation', 'welcometocoursetext', 'backpackemailverifyemailbody' and 'lockoutemailbody' strings adding an HTML tag. For example, add first greetings into '<b></b>' tags. And add some newlines as well.
      4. Purge caches

      New user's passwords

      1. As site admin go to Site administration > Users > Upload users
      2. Upload attached MDL-61649.csv file, check 'New user password' = 'Create password if needed and send via email'
      3. Upload users and continue the process.
      4. Run the cron
      5. Confirm email1 user's email renderers HTML tags properly 
      6. Confirm email2 user's email doesn't show the HTML tag added but creates new lines

      Self-registration emails

      1. Go to Site administration > Plugins > Authentication and check 'Email-based self-registration' is enabled.
      2. Go to Site administration > Users > Accounts > User default preferences
      3. Confirm 'Email format' = 'Pretty HTML format' and Save changes if needed
      4. Log out
      5. Click on 'Create new account' button in the main login page
      6. Create a new email3 account.
      7. Confirm email3 user's email renderers HTML tags properly
      8. As an admin go to Site administration > Users > Accounts > User default preferences
      9. Confirm 'Email format' = 'Plain text' and Save changes
      10. Log out
      11. Click on 'Create new account' button in the main login page
      12. Create a new email4 account.
      13. Confirm email4 user's email doesn't show the HTML tag added but creates new lines

      Reset password

      1. Click on 'Forgotten your username or password?' link in the main login page
      2. Fill 'Username' field with 'email1' and click Search button
      3. Confirm email1 user's email renderers HTML tags properly
      4. Click on 'Forgotten your username or password?' link in the main login page
      5. Fill 'Username' field with 'email2' and click Search button
      6. Confirm email2 user's email doesn't show the HTML tag added but creates new lines

      Self-enrolment emails

      1. As an admin create a new course and enable 'Self enrolment' enrolment method for it
      2. Log out
      3. Log in as as email1 user
      4. Enrol in the new course
      5. Confirm email1 user's email renderers HTML tags properly
      6. Log out
      7. Log in as as email2 user
      8. Enrol in the new course
      9. Confirm email2 user's email doesn't show the HTML tag added but creates new lines

      Badges confirmation

      1. Log in as email1 user
      2. Go to User preferences > Backpack settings. Use an existing email account for the backpack URL in the 'Email address' field and click 'Connect to backpack'
      3. Log out
      4. Log in as emai2 user
      5. Go to User preferences > Backpack settings. Use an existing email account for the backpack URL in the 'Email address' field and click 'Connect to backpack'
      6. Log out
      7. Confirm email1 user's email renderers HTML tags properly
      8. Confirm email2 user's email doesn't show the HTML tag added but creates new lines

      Locked accounts

      1. As an admin go to Site administration > Security > Site security settings and change 'Account lockout threshold' = 3 and Save Changes
      2. Log out
      3. Try to login as email1 user with a wrong password more than 3 times
      4. Try to login as email2 user with a wrong password more than 3 times
      5. Confirm email1 user's email renderers HTML tags properly
      6. Confirm email2 user's email doesn't show the HTML tag added but creates new lines
      Show
      Prerequisites Set-up mailcatcher ( https://mailcatcher.me/ ). Log in as an admin. Visit ‘Site administration’ > ‘Server’ > ‘Outgoing mail configuration’. Set the 'SMTP hosts' field to '127.0.0.1:1025'. Save. An active account at https://backpack.openbadges.org Testing As site admin go to Site administration > Language > Language Customisation Choose English and Open language pack for editing Edit 'newusernewpasswordtext', 'emailconfirmation', 'emailresetconfirmation', 'welcometocoursetext', 'backpackemailverifyemailbody' and 'lockoutemailbody' strings adding an HTML tag. For example, add first greetings into '<b></b>' tags. And add some newlines as well. Purge caches New user's passwords As site admin go to Site administration > Users > Upload users Upload attached MDL-61649 .csv file, check 'New user password' = 'Create password if needed and send via email' Upload users and continue the process. Run the cron Confirm email1 user's email renderers HTML tags properly  Confirm email2 user's email doesn't show the HTML tag added but creates new lines Self-registration emails Go to Site administration > Plugins > Authentication and check 'Email-based self-registration' is enabled. Go to Site administration > Users > Accounts > User default preferences Confirm 'Email format' = 'Pretty HTML format' and Save changes if needed Log out Click on 'Create new account' button in the main login page Create a new email3 account. Confirm email3 user's email renderers HTML tags properly As an admin go to Site administration > Users > Accounts > User default preferences Confirm 'Email format' = 'Plain text' and Save changes Log out Click on 'Create new account' button in the main login page Create a new email4 account. Confirm email4 user's email doesn't show the HTML tag added but creates new lines Reset password Click on 'Forgotten your username or password?' link in the main login page Fill 'Username' field with 'email1' and click Search button Confirm email1 user's email renderers HTML tags properly Click on 'Forgotten your username or password?' link in the main login page Fill 'Username' field with 'email2' and click Search button Confirm email2 user's email doesn't show the HTML tag added but creates new lines Self-enrolment emails As an admin create a new course and enable 'Self enrolment' enrolment method for it Log out Log in as as email1 user Enrol in the new course Confirm email1 user's email renderers HTML tags properly Log out Log in as as email2 user Enrol in the new course Confirm email2 user's email doesn't show the HTML tag added but creates new lines Badges confirmation Log in as email1 user Go to User preferences > Backpack settings. Use an existing email account for the backpack URL in the 'Email address' field and click 'Connect to backpack' Log out Log in as emai2 user Go to User preferences > Backpack settings. Use an existing email account for the backpack URL in the 'Email address' field and click 'Connect to backpack' Log out Confirm email1 user's email renderers HTML tags properly Confirm email2 user's email doesn't show the HTML tag added but creates new lines Locked accounts As an admin go to Site administration > Security > Site security settings and change 'Account lockout threshold' = 3 and Save Changes Log out Try to login as email1 user with a wrong password more than 3 times Try to login as email2 user with a wrong password more than 3 times Confirm email1 user's email renderers HTML tags properly Confirm email2 user's email doesn't show the HTML tag added but creates new lines
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_37_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-61649-master
    • Story Points:
      1
    • Sprint:
      Moppies Moodle 3.8 Sprint 1, Moppies Moodle 3.8 Sprint 2, Moppies Moodle 3.8 Sprint 3, Moppies Moodle 3.8 Sprint 4

      Description

      Some core emails (see list below) only provide the email_to_user function with a text format message rather than providing the (currently optional) HTML message as well.

      This has two drawbacks:

      1) Users who opt to receive HTML emails, will sometimes (with no obvious pattern) recieve text emails from their Moodle site which might make them wonder if their settings are correct and/or if these messages are really coming from their Moodle. Many of these messages are around authentication, so that confidence is probably important.

      2) Sites that use the new email wrapping mustache templates core/html_email.mustache will have these text only emails automatically converted to HTML, which works fine for text only content, but anything with a link in it will no longer be clickable, just displayed as text.

       $autohtml = trim(text_to_html($messagetext));

      Possible areas to improve:

      lib/authlib.php
      781=function login_lock_account($user) {
      822:            email_to_user($user, $supportuser, $subject, $message);

      lib/classes/task/send_failed_login_notifications_task.php
      29=class send_failed_login_notifications_task extends scheduled_task {
      177:                email_to_user($admin, \core_user::get_noreply_user(), $subject, $body);

      lib/moodlelib.php
      6100=function setnew_password_and_mail($user, $fasthash = false) {
      6129:    return email_to_user($user, $supportuser, $subject, $message);
      6139=function reset_password_and_mail($user) {
      6173:    return email_to_user($user, $supportuser, $subject, $message);
      6232=function send_password_change_confirmation_email($user, $resetrecord) {
      6252:    return email_to_user($user, $supportuser, $subject, $message);
      6262=function send_password_change_info($user) {
      6282:        return email_to_user($user, $supportuser, $subject, $message);
      6303:    return email_to_user($user, $supportuser, $subject, $message);

      user/edit.php
      273:        if (!$mailresults = email_to_user($tempuser, $noreplyuser, $emailupdatetitle, $emailupdatemessage)) {

       

      Possibly it's worth considering making the HTML format non-optional.

        Attachments

        1. MDL-61649.csv
          0.1 kB
        2. screenshot-1.png
          screenshot-1.png
          296 kB
        3. without-patch-no-lang-custom.png
          without-patch-no-lang-custom.png
          672 kB
        4. with-patch-no-lang-custom.png
          with-patch-no-lang-custom.png
          648 kB

          Issue Links

            Activity

              People

              • Votes:
                9 Vote for this issue
                Watchers:
                15 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  18/Nov/19

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 4 hours
                  1d 4h