diff --git a/class.phpmailer.php b/class.phpmailer.php index f5ca89709..b467c716f 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -479,6 +479,13 @@ class PHPMailer */ protected $CustomHeader = array(); + /** + * The most recent Message-ID (including angular brackets). + * @type string + * @access protected + */ + protected $lastMessageID = ''; + /** * The message's MIME type. * @type string @@ -806,6 +813,18 @@ public function setFrom($address, $name = '', $auto = true) return true; } + /** + * Return the Message-ID header of the last email. + * Technically this is the value from the last time the headers were created, + * but it also the message ID of the last sent message except in + * pathological cases. + * @return string + */ + public function GetLastMessageID() + { + return $this->lastMessageID; + } + /** * Check that a string looks like an email address. * @param string $address The email address to check @@ -1606,10 +1625,11 @@ public function createHeader() } if ($this->MessageID != '') { - $result .= $this->headerLine('Message-ID', $this->MessageID); + $this->lastMessageID = $this->MessageID; } else { - $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->serverHostname(), $this->LE); + $this->lastMessageID = sprintf("<%s@%s>", $uniq_id, $this->ServerHostname()); } + $result .= $this->HeaderLine('Message-ID', $this->lastMessageID); $result .= $this->headerLine('X-Priority', $this->Priority); if ($this->XMailer == '') { $result .= $this->headerLine( @@ -2914,7 +2934,7 @@ public static function _mime_types($ext = '') 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie' ); - return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; + return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream'); } /**