From e23ad0419d15902904d9e11806a423ae3565ea26 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Thu, 11 Aug 2016 12:22:48 +1200 Subject: [PATCH] CRM-19215. Handle peculiar format of From header. --- CRM/Utils/Mail/Incoming.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CRM/Utils/Mail/Incoming.php b/CRM/Utils/Mail/Incoming.php index a3c869402e..cc652f0fdc 100644 --- a/CRM/Utils/Mail/Incoming.php +++ b/CRM/Utils/Mail/Incoming.php @@ -318,6 +318,14 @@ class CRM_Utils_Mail_Incoming { // and put it in a standardized format $params = array('is_error' => 0); + // Sometimes $mail->from is unset because ezcMail didn't handle format + // of From header. CRM-19215. + if (!isset($mail->from)) { + if (preg_match('/^([^ ]*)( (.*))?$/', $mail->getHeader('from'), $matches)) { + $mail->from = new ezcMailAddress($matches[1], trim($matches[2])); + } + } + $params['from'] = array(); self::parseAddress($mail->from, $field, $params['from'], $mail); -- 2.25.1