From 370b3ed6f866ee21150fc9ba548a653bdf22e96a Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 7 Feb 2024 16:10:55 +0300 Subject: [PATCH] add message property check, handling imap_fetchstructure errors --- src/Fetch/Message.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Fetch/Message.php b/src/Fetch/Message.php index 1836755..34b6ee7 100644 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -249,9 +249,15 @@ class Message return false; - $this->subject = MIME::decode($messageOverview->subject, self::$charset); - $this->date = strtotime($messageOverview->date); - $this->size = $messageOverview->size; + if (property_exists($messageOverview, 'subject')) { + $this->subject = MIME::decode($messageOverview->subject, self::$charset); + } + + if (property_exists($messageOverview, 'date')) { + $this->date = strtotime($messageOverview->date); + } + + $this->size = $messageOverview->size; foreach (self::$flagTypes as $flag) $this->status[$flag] = ($messageOverview->$flag == 1); @@ -381,7 +387,7 @@ class Message public function getStructure($forceReload = false) { if ($forceReload || !isset($this->structure)) { - $this->structure = imap_fetchstructure($this->imapStream, $this->uid, FT_UID); + $this->structure = @imap_fetchstructure($this->imapStream, $this->uid, FT_UID); } return $this->structure; @@ -532,6 +538,10 @@ class Message */ protected function processStructure($structure, $partIdentifier = null) { + if (!$structure) { + return; + } + $parameters = self::getParametersFromStructure($structure); // quick fix for Content-Disposition extended notation