@@ -1249,9 +1249,9 @@ public function getMail(int $mailId, bool $markAsSeen = true): IncomingMail
1249
1249
*
1250
1250
* @return IncomingMailAttachment $attachment
1251
1251
*/
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
1253
1253
{
1254
- if ('RFC822 ' == $ partStructure ->subtype && isset ($ partStructure ->disposition ) && ' attachment ' == $ partStructure -> disposition ) {
1254
+ if ('RFC822 ' == $ partStructure ->subtype && isset ($ partStructure ->disposition ) && $ dispositionAttachment ) {
1255
1255
$ fileName = \strtolower ($ partStructure ->subtype ).'.eml ' ;
1256
1256
} elseif ('ALTERNATIVE ' == $ partStructure ->subtype ) {
1257
1257
$ fileName = \strtolower ($ partStructure ->subtype ).'.eml ' ;
@@ -1674,10 +1674,10 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
1674
1674
}
1675
1675
1676
1676
// 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 ) {
1678
1678
// Although we are downloading each part separately, we are going to download the EML to a single file
1679
1679
//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 );
1681
1681
$ mail ->addAttachment ($ attachment );
1682
1682
}
1683
1683
@@ -1695,7 +1695,7 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
1695
1695
}
1696
1696
1697
1697
if ($ isAttachment ) {
1698
- $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , $ emlParse );
1698
+ $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , $ emlParse, $ dispositionAttachment );
1699
1699
$ mail ->addAttachment ($ attachment );
1700
1700
} else {
1701
1701
if (isset ($ params ['charset ' ]) && !empty (\trim ($ params ['charset ' ]))) {
@@ -1705,14 +1705,14 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
1705
1705
1706
1706
if (!empty ($ partStructure ->parts )) {
1707
1707
foreach ($ partStructure ->parts as $ subPartNum => $ subPartStructure ) {
1708
- $ not_attachment = (!isset ($ partStructure ->disposition ) || ' attachment ' !== $ partStructure -> disposition );
1708
+ $ not_attachment = (!isset ($ partStructure ->disposition ) || ! $ dispositionAttachment );
1709
1709
1710
1710
if (TYPEMESSAGE === $ partStructure ->type && 'RFC822 ' === $ partStructure ->subtype && $ not_attachment ) {
1711
1711
$ this ->initMailPart ($ mail , $ subPartStructure , $ partNum , $ markAsSeen );
1712
1712
} elseif (TYPEMULTIPART === $ partStructure ->type && 'ALTERNATIVE ' === $ partStructure ->subtype && $ not_attachment ) {
1713
1713
// https://github.com/barbushin/php-imap/issues/198
1714
1714
$ 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 ) {
1716
1716
//If it comes from am EML attachment, download each part separately as a file
1717
1717
$ this ->initMailPart ($ mail , $ subPartStructure , $ partNum .'. ' .($ subPartNum + 1 ), $ markAsSeen , true );
1718
1718
} else {
0 commit comments