From 8f27fdf1ab4097a50bcfeb344db5ffba5f437473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Wed, 21 Dec 2016 01:11:32 +0100 Subject: [PATCH] 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. --- lib/phpmailer/moodle_phpmailer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/phpmailer/moodle_phpmailer.php b/lib/phpmailer/moodle_phpmailer.php index a25b99260e3..63abdeb7254 100644 --- a/lib/phpmailer/moodle_phpmailer.php +++ b/lib/phpmailer/moodle_phpmailer.php @@ -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);