diff --git a/src/Fetch/Message.php b/src/Fetch/Message.php index e382678..f7843c3 100755 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -562,15 +562,21 @@ protected function processStructure($structure, $partIdentifier = null) } } - if (isset($structure->parts)) { // multipart: iterate through each part + if (! empty($structure->parts)) { - foreach ($structure->parts as $partIndex => $part) { - $partId = $partIndex + 1; + if (isset($structure->subtype) && strtolower($structure->subtype) === 'rfc822') { + // rfc822: The root part is processed with the current part identifier + $this->processStructure($structure->parts[0], $partIdentifier); + } else { + // multipart: iterate through each part + foreach ($structure->parts as $partIndex => $part) { + $partId = $partIndex + 1; - if (isset($partIdentifier)) - $partId = $partIdentifier . '.' . $partId; + if (isset($partIdentifier)) + $partId = $partIdentifier . '.' . $partId; - $this->processStructure($part, $partId); + $this->processStructure($part, $partId); + } } } }