MDL-48899 lib: Use the wwwroot to inform the message-ID
PHPMailer can sometimes fail to get a valid hostname when trying to determine a Message-ID. Rather than relying entirely on the serverHostname, fall back on the wwwroot when unable to determine the real hostname.
This commit is contained in:
@@ -162,4 +162,22 @@ class moodle_phpmailer extends PHPMailer {
|
||||
return parent::postSend();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server hostname.
|
||||
* Returns the host part of the wwwroot.
|
||||
*
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function serverHostname() {
|
||||
global $CFG;
|
||||
|
||||
$hostname = parent::serverHostname();
|
||||
if ($hostname === 'localhost.localdomain') {
|
||||
$urlinfo = parse_url($CFG->wwwroot);
|
||||
$hostname = $urlinfo['host'];
|
||||
}
|
||||
return $hostname;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user