Skip to content

Commit

Permalink
MDL-57474 mailer: Make sure that our exlicit MessageID is trimmed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mudrd8mz committed Dec 21, 2016
1 parent 5100c48 commit 657fa9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/phpmailer/moodle_phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public function __construct(){
*/
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);
Expand Down

0 comments on commit 657fa9d

Please sign in to comment.