From 882311bb2b80506fe24f0cc2eb17f619ad6f1152 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Wed, 5 Feb 2014 09:54:22 -0600 Subject: [PATCH] Search for system emails in To and Delivered-To Previously, the Delivered-To header was only used if the To header was not found --- include/class.mailparse.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/class.mailparse.php b/include/class.mailparse.php index 141d18f96..17da5f590 100644 --- a/include/class.mailparse.php +++ b/include/class.mailparse.php @@ -172,11 +172,15 @@ class Mail_Parse { function getToAddressList(){ // Delivered-to incase it was a BBC mail. - if (!($header = $this->struct->headers['to'])) - if (!($header = $this->struct->headers['delivered-to'])) - return null; + $addrs = array(); + if ($header = $this->struct->headers['to']) + $addrs = Mail_Parse::parseAddressList($header); - return Mail_Parse::parseAddressList($header); + if ($header = $this->struct->headers['delivered-to']) + $addrs = array_merge($addrs, + Mail_Parse::parseAddressList($header)); + + return $addrs; } function getCcAddressList(){ @@ -394,6 +398,10 @@ class Mail_Parse { function parseAddressList($address){ if (!$address) return false; + // Delivered-To may appear more than once in the email headers + if (is_array($address)) + $address = implode(', ', $address); + return Mail_RFC822::parseAddressList($address, null, null,false); } -- GitLab