-
Bug
-
Resolution: Fixed
-
Minor
-
3.4.5, 3.5.1, 3.6, 4.4.5, 4.5.1
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
- has been marked as being related by
-
MDL-4188 Send course welcome message for manual and self enrolments
-
- Closed
-