From 8c94035ccd06e621f74f85f768686082f7dd97bb Mon Sep 17 00:00:00 2001 From: viacoding Date: Mon, 28 Jan 2019 09:48:20 +0100 Subject: [PATCH] - fixed issue #225 from giuspe --- ImapClient/IncomingMessage.php | 44 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/ImapClient/IncomingMessage.php b/ImapClient/IncomingMessage.php index 1bd4825..81719ce 100644 --- a/ImapClient/IncomingMessage.php +++ b/ImapClient/IncomingMessage.php @@ -362,27 +362,29 @@ protected function getBody() foreach ($this->getSections(self::SECTION_BODY) as $section) { $obj = $this->getSection($section, array('class' => $subType)); $subtype = strtolower($obj->__get('structure')->subtype); - if (!isset($objNew->$subtype)) { - $objNew->$subtype = $obj; - } else { - $subtype = $subtype.'_'.$i; - $objNew->$subtype = $obj; - $i++; - } - $objNew->info[] = $obj; - $objNew->types[] = $subtype; - /* - * Set charset - */ - foreach ($objNew->$subtype->__get('structure')->parameters as $parameter) { - $attribute = strtolower($parameter->attribute); - if ($attribute === 'charset') { - $value = strtolower($parameter->value); - /* - * Here must be array, but - */ - //$objNew->$subtype->charset[] = $value; - $objNew->$subtype->charset = $value; + if(!empty($subtype)) { + if (!isset($objNew->$subtype)) { + $objNew->$subtype = $obj; + } else { + $subtype = $subtype.'_'.$i; + $objNew->$subtype = $obj; + $i++; + } + $objNew->info[] = $obj; + $objNew->types[] = $subtype; + /* + * Set charset + */ + foreach ($objNew->$subtype->__get('structure')->parameters as $parameter) { + $attribute = strtolower($parameter->attribute); + if ($attribute === 'charset') { + $value = strtolower($parameter->value); + /* + * Here must be array, but + */ + //$objNew->$subtype->charset[] = $value; + $objNew->$subtype->charset = $value; + } } } }