File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1313use ZBateson \MailMimeParser \Header \Part \ContainerPart ;
1414use ZBateson \MailMimeParser \Header \Part \NameValuePart ;
1515use ZBateson \MailMimeParser \Message as MailMimeMessage ;
16+ use ZBateson \MailMimeParser \Message \IMessagePart ;
1617
1718trait HasParsedMessage
1819{
@@ -121,10 +122,7 @@ public function attachments(): array
121122 $ attachments = [];
122123
123124 foreach ($ this ->parse ()->getAllAttachmentParts () as $ part ) {
124- // If the attachment's content type is message/rfc822, we're
125- // working with a forwarded message. We will parse the
126- // forwarded message and merge in its attachments.
127- if (strtolower ($ part ->getContentType ()) === 'message/rfc822 ' ) {
125+ if ($ this ->isForwardedMessage ($ part )) {
128126 $ message = new FileMessage ($ part ->getContent ());
129127
130128 $ attachments = array_merge ($ attachments , $ message ->attachments ());
@@ -157,6 +155,16 @@ public function attachmentCount(): int
157155 return $ this ->parse ()->getAttachmentCount ();
158156 }
159157
158+ /**
159+ * Determine if the attachment should be treated as an embedded forwarded message.
160+ */
161+ protected function isForwardedMessage (IMessagePart $ part ): bool
162+ {
163+ return empty ($ part ->getFilename ())
164+ && strtolower ((string ) $ part ->getContentType ()) === 'message/rfc822 '
165+ && strtolower ((string ) $ part ->getContentDisposition ()) !== 'attachment ' ;
166+ }
167+
160168 /**
161169 * Get addresses from the given header.
162170 *
You can’t perform that action at this time.
0 commit comments