From 2a44e95388676fc325569d8b0f80698f9bf43a0b Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 17 Oct 2013 19:37:13 +0000 Subject: [PATCH] Handle parsing email if Reply-To header is missing --- include/class.mailparse.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/include/class.mailparse.php b/include/class.mailparse.php index 039a48b74..dbcbf769b 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -132,16 +132,26 @@ class Mail_Parse { function getFromAddressList(){ - return Mail_Parse::parseAddressList($this->struct->headers['from']); + if (!($header = $this->struct->headers['from'])) + return null; + + return Mail_Parse::parseAddressList($header); } function getToAddressList(){ - //Delivered-to incase it was a BBC mail. - return Mail_Parse::parseAddressList($this->struct->headers['to']?$this->struct->headers['to']:$this->struct->headers['delivered-to']); + // Delivered-to incase it was a BBC mail. + if (!($header = $this->struct->headers['to'])) + if (!($header = $this->struct->headers['delivered-to'])) + return null; + + return Mail_Parse::parseAddressList($header); } function getCcAddressList(){ - return $this->struct->headers['cc']?Mail_Parse::parseAddressList($this->struct->headers['cc']):null; + if (!($header = $this->struct->headers['cc'])) + return null; + + return Mail_Parse::parseAddressList($header); } function getMessageId(){ @@ -153,7 +163,10 @@ class Mail_Parse { } function getReplyTo() { - return Mail_Parse::parseAddressList($this->struct->headers['reply-to']); + if (!($header = $this->struct->headers['reply-to'])) + return null; + + return Mail_Parse::parseAddressList($header); } function getBody(){ @@ -371,7 +384,7 @@ class EmailDataParser { $data['in-reply-to'] = $parser->struct->headers['in-reply-to']; $data['references'] = $parser->struct->headers['references']; - if ($replyto = $parser->getReplyTo()) { + if (($replyto = $parser->getReplyTo()) && !PEAR::isError($replyto)) { $replyto = $replyto[0]; $data['reply-to'] = $replyto->mailbox.'@'.$replyto->host; if ($replyto->personal) -- GitLab