MDL-57474 mailer: Make sure that our exlicit MessageID is trimmed

The new version of phpmailer shipped with Moodle 3.2 has added check
that the explicitly provided MessageID matches /^<.*@.*>$/.

Values coming from our overridden moodle_phpmailer::addCustomHeader()
had a whitespace at the start. So the requested value was not used as
the Message-ID header and the default phpmailer value was used.

As a result, forum posts threading was broken in email clients.
This commit is contained in:
David Mudrák
2016-12-21 01:11:32 +01:00
parent 1ca30f2503
commit 8f27fdf1ab
+2 -2
View File
@@ -74,10 +74,10 @@ class moodle_phpmailer extends PHPMailer {
*/
public function addCustomHeader($custom_header, $value = null) {
if ($value === null and preg_match('/message-id:(.*)/i', $custom_header, $matches)) {
$this->MessageID = $matches[1];
$this->MessageID = trim($matches[1]);
return true;
} else if ($value !== null and strcasecmp($custom_header, 'message-id') === 0) {
$this->MessageID = $value;
$this->MessageID = trim($value);
return true;
} else {
return parent::addCustomHeader($custom_header, $value);