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

Course welcome email always comes from no-reply address (fails can_send_from_real_email_address)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.4.5, 4.5.1
    • 3.4.5, 3.5.1, 3.6, 4.4.5, 4.5.1
    • Enrolments

      Reproduce

      • Create a course in Moodle and enroll a teacher
      • Make sure teacher's email address is in 'Allowed email domains' of Outgoing Mail Configuration
      • Enable the Self-enrollment method
      • Ensure the Send course welcome message is set to Course Contact
      • Have another user self enroll in the course
      • Course Welcome email includes contact name, but is sent from no-reply address.

      Issue

      The course welcome messages is not coming from the email address of the course contact, even when specified in the settings and the contact's preferences are set to "Allow everyone to see my email address" and the contact's email is in the Allowed email domains.

      Cause

      The function can_send_from_real_email_address relies on checking the maildisplay property of the $from parameter. Without this property present, the following warnings are present in the log:

      [Tue Nov 12 21:22:20.916008 2024] [php:warn] [pid 35:tid 35] [client 172.18.0.1:47330] PHP Warning:  Undefined property: stdClass::$maildisplay in /var/www/html/lib/moodlelib.php on line 5959, referer: http://localhost:8000/user/index.php?id=2
      [Tue Nov 12 21:22:20.916037 2024] [php:warn] [pid 35:tid 35] [client 172.18.0.1:47330] PHP Warning:  Undefined property: stdClass::$maildisplay in /var/www/html/lib/moodlelib.php on line 5960, referer: http://localhost:8000/user/index.php?id=2
      

      In the self enrollment plugin (enrol/self/lib.php), the get_welcome_email_contact does not include this property in the returned user object, so the check always returns false.

      Solution

      Add the maildisplay property to the returned contact object of get_welcome_email_contact. This will allow the from email address of the course contact to be used if their preference is set to "Allow everyone to see my email address."

      See public repo:

      https://github.com/zrisha/moodle/tree/MDL-63264-master-fix-welcome-email

       

            pholden Paul Holden
            zrisha zrisha
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Huong Nguyen Huong Nguyen
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 41 minutes
                2h 41m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.