Fixing mail configuration to be coherent on FROM email address refs BT#16207

pull/3023/head
Nicolas Ducoulombier 6 years ago
parent b1a33bf6d8
commit 6b8c9e22be
  1. 4
      app/config/mail.conf.dist.php
  2. 4
      main/inc/lib/api.lib.php
  3. 7
      main/inc/lib/notification.lib.php

@ -6,8 +6,8 @@
* @package chamilo.configuration
*/
$platform_email['SMTP_FROM_EMAIL'] = (isset($administrator['email']) ? $administrator['email'] : 'admin@example.com');
$platform_email['SMTP_FROM_NAME'] = (isset($administrator['name']) ? $administrator['name'] : 'Admin');
$platform_email['SMTP_FROM_EMAIL'] = ''; //See the function __construct() in main/inc/lib/notification.lib.php for more details on how the SMTP FROM email is defined and what to indicate here if needed to override users configuration
$platform_email['SMTP_FROM_NAME'] = '';
$platform_email['SMTP_HOST'] = 'localhost';
$platform_email['SMTP_PORT'] = 25;
$platform_email['SMTP_MAILER'] = 'mail'; // mail, sendmail or smtp (Windows probably only supports smtp)

@ -9566,8 +9566,8 @@ function api_set_noreply_and_from_address_to_mailer(PHPMailer $mailer, array $se
isset($platformEmail['SMTP_UNIQUE_SENDER']) &&
$platformEmail['SMTP_UNIQUE_SENDER']
) {
$senderName = $platformEmail['SMTP_FROM_NAME'];
$senderEmail = $platformEmail['SMTP_FROM_EMAIL'];
$senderName = $notification->getDefaultPlatformSenderName();
$senderEmail = $notification->getDefaultPlatformSenderEmail();
if (PHPMailer::ValidateAddress($senderEmail)) {
//force-set Sender to $senderEmail, otherwise SetFrom only does it if it is currently empty

@ -62,6 +62,12 @@ class Notification extends Model
public function __construct()
{
$this->table = Database::get_main_table(TABLE_NOTIFICATION);
if (!empty($platform_email['SMTP_FROM_EMAIL'])) {
$this->adminEmail = $platform_email['SMTP_FROM_EMAIL'];
if (!empty($platform_email['SMTP_FROM_NAME'])) {
$this->adminName = $platform_email['SMTP_FROM_NAME'];
}
} else {
// Default no-reply email
$this->adminEmail = api_get_setting('noreply_email_address');
$this->adminName = api_get_setting('siteName');
@ -78,6 +84,7 @@ class Notification extends Model
);
}
}
}
/**
* @return string

Loading…
Cancel
Save