@@ -1249,9 +1249,9 @@ public function getMail(int $mailId, bool $markAsSeen = true): IncomingMail
12491249 *
12501250 * @return IncomingMailAttachment $attachment
12511251 */
1252- public function downloadAttachment (DataPartInfo $ dataInfo , array $ params , object $ partStructure , bool $ emlOrigin = false ): IncomingMailAttachment
1252+ public function downloadAttachment (DataPartInfo $ dataInfo , array $ params , object $ partStructure , bool $ emlOrigin = false , bool $ dispositionAttachment = false ): IncomingMailAttachment
12531253 {
1254- if ('RFC822 ' == $ partStructure ->subtype && isset ($ partStructure ->disposition ) && ' attachment ' == $ partStructure -> disposition ) {
1254+ if ('RFC822 ' == $ partStructure ->subtype && isset ($ partStructure ->disposition ) && $ dispositionAttachment ) {
12551255 $ fileName = \strtolower ($ partStructure ->subtype ).'.eml ' ;
12561256 } elseif ('ALTERNATIVE ' == $ partStructure ->subtype ) {
12571257 $ fileName = \strtolower ($ partStructure ->subtype ).'.eml ' ;
@@ -1674,10 +1674,10 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
16741674 }
16751675
16761676 // check if the part is a subpart of another attachment part (RFC822)
1677- if ('RFC822 ' === $ partStructure ->subtype && isset ($ partStructure ->disposition ) && ' attachment ' === $ partStructure -> disposition ) {
1677+ if ('RFC822 ' === $ partStructure ->subtype && isset ($ partStructure ->disposition ) && $ dispositionAttachment ) {
16781678 // Although we are downloading each part separately, we are going to download the EML to a single file
16791679 //incase someone wants to process or parse in another process
1680- $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , false );
1680+ $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , false , $ dispositionAttachment );
16811681 $ mail ->addAttachment ($ attachment );
16821682 }
16831683
@@ -1695,7 +1695,7 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
16951695 }
16961696
16971697 if ($ isAttachment ) {
1698- $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , $ emlParse );
1698+ $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , $ emlParse, $ dispositionAttachment );
16991699 $ mail ->addAttachment ($ attachment );
17001700 } else {
17011701 if (isset ($ params ['charset ' ]) && !empty (\trim ($ params ['charset ' ]))) {
@@ -1705,14 +1705,14 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
17051705
17061706 if (!empty ($ partStructure ->parts )) {
17071707 foreach ($ partStructure ->parts as $ subPartNum => $ subPartStructure ) {
1708- $ not_attachment = (!isset ($ partStructure ->disposition ) || ' attachment ' !== $ partStructure -> disposition );
1708+ $ not_attachment = (!isset ($ partStructure ->disposition ) || ! $ dispositionAttachment );
17091709
17101710 if (TYPEMESSAGE === $ partStructure ->type && 'RFC822 ' === $ partStructure ->subtype && $ not_attachment ) {
17111711 $ this ->initMailPart ($ mail , $ subPartStructure , $ partNum , $ markAsSeen );
17121712 } elseif (TYPEMULTIPART === $ partStructure ->type && 'ALTERNATIVE ' === $ partStructure ->subtype && $ not_attachment ) {
17131713 // https://github.com/barbushin/php-imap/issues/198
17141714 $ this ->initMailPart ($ mail , $ subPartStructure , $ partNum , $ markAsSeen );
1715- } elseif ('RFC822 ' === $ partStructure ->subtype && isset ($ partStructure ->disposition ) && ' attachment ' === $ partStructure -> disposition ) {
1715+ } elseif ('RFC822 ' === $ partStructure ->subtype && isset ($ partStructure ->disposition ) && $ dispositionAttachment ) {
17161716 //If it comes from am EML attachment, download each part separately as a file
17171717 $ this ->initMailPart ($ mail , $ subPartStructure , $ partNum .'. ' .($ subPartNum + 1 ), $ markAsSeen , true );
17181718 } else {
0 commit comments