Title: Wrong Email Sender for Test Notification in Learning Path - Email Sender Issue After Upgrade to Version 1.11.28
After recently upgrading our portal from version 1.11.16 to 1.11.28, we’ve noticed an issue with the notification emails sent to admins when a participant completes a test. Previously, these emails were sent from the portal's email address, but now they are sent from the participant's registered email address. The reply-to address, however, remains set to the portal’s email address.
This change has led to many of these emails being marked as spam. Is it possible to revert to the original configuration, or is there a new setting in the updated configuration files that might control this behavior? I checked the config files but couldn't locate any relevant option.
Registration emails and similar notifications are still sent correctly from the portal's address; the issue only affects completion notifications.
Example from version 1.11.16:
Subject: You have a new message from [Participant Name]
Date: 2024-10-18 21:11
From: "[email protected]" [email protected]
To: [Admin Name] [email protected]
Reply-To: [Participant Name] [email protected]
Example from the new version:
From: [Participant Name] [email protected]
Sent: Tuesday, November 12, 2024 10:44
To: [Admin Name] [email protected]
Subject: You have a new message from [Participant Name]
Can someone tell me in which PHP file the email generation for completed tests in the learning paths is done?
It seems that this commit introduces the issue:
https://github.com/chamilo/chamilo-lms/commit/50dfee4881c4432b24ceb9cc467069eee0d8adbe
It looks like:
'sender' => $senderUserIri,
should be:
'sender' => $admin,
This issue is still active. Any news about this?
Hi @Bavarianspirit We're finishing V2 alpha 2 and then I will be looking at all pending issues for 1.11.*. Sorry about the delay and thank you for the debug efforts.
Hi @Bavarianspirit The commit you were pointing to (50dfee4) is from automated tests, so I don't see how it could be related to your issue. Discarded.
So the message "You have a new message from %s" (where %s is replaced by a variable) is only used in 2 places in main/inc/lib/notification.lib.php: formatTitle() and formatContent().
These 2 methods are used only by saveNotification() in the same library. The same saveNotification() method calls api_mail_html(), which is the one sending the e-mail, with a senderEmail param of !empty($senderInfo['email']) ? $senderInfo['email'] : $this->adminEmail. In other words, we use the admin e-mail only if the sender e-mail is not provided, and there's no further check on which e-mail should be used, so we have to change the sender e-mail for the admin's e-mail before we get to that api_mail_html() call.
The method saveNotification() is used in SocialManager::send_invitation_friend() (which has to do with the social network, so not interesting here) and in MessageManager::send_message(), which is a bit more generic (called from 27 different places in the code).
This brings us to a more generic solution, which is that we have added a setting in app/config/mail.conf.php to specifically set a unique sender for the e-mails (which is the most logical choice in most cases, including yours):
$platform_email['SMTP_UNIQUE_SENDER'] = 0;
By setting this to 1, your Chamilo portal will always use only the e-mail defined a few lines above in mail.conf.php:
$platform_email['SMTP_FROM_EMAIL'] = '[the generic e-mail]';
Or if you haven't defined that one, it will search for your setting (in the web interface) of noreply_email_address.
If that one was not defined either, then it will look for the setting emailAdministrator (also in the web interface).
I think this closes the issue, because there is a solution without modifying the code, and it seems to satisfy your needs.
Let me know.