@@ -1250,9 +1250,9 @@ public function getMail(int $mailId, bool $markAsSeen = true): IncomingMail
1250
1250
*
1251
1251
* @return IncomingMailAttachment $attachment
1252
1252
*/
1253
- public function downloadAttachment (DataPartInfo $ dataInfo , array $ params , object $ partStructure , bool $ emlOrigin = false ): IncomingMailAttachment
1253
+ public function downloadAttachment (DataPartInfo $ dataInfo , array $ params , object $ partStructure , bool $ emlOrigin = false , bool $ dispositionAttachment = false ): IncomingMailAttachment
1254
1254
{
1255
- if ('RFC822 ' == $ partStructure ->subtype && isset ($ partStructure ->disposition ) && ' attachment ' == $ partStructure -> disposition ) {
1255
+ if ('RFC822 ' == $ partStructure ->subtype && isset ($ partStructure ->disposition ) && $ dispositionAttachment ) {
1256
1256
$ fileName = \strtolower ($ partStructure ->subtype ).'.eml ' ;
1257
1257
} elseif ('ALTERNATIVE ' == $ partStructure ->subtype ) {
1258
1258
$ fileName = \strtolower ($ partStructure ->subtype ).'.eml ' ;
@@ -1659,10 +1659,10 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
1659
1659
}
1660
1660
1661
1661
// check if the part is a subpart of another attachment part (RFC822)
1662
- if ('RFC822 ' === $ partStructure ->subtype && isset ($ partStructure ->disposition ) && ' attachment ' === $ partStructure -> disposition ) {
1662
+ if ('RFC822 ' === $ partStructure ->subtype && isset ($ partStructure ->disposition ) && $ dispositionAttachment ) {
1663
1663
// Although we are downloading each part separately, we are going to download the EML to a single file
1664
1664
//incase someone wants to process or parse in another process
1665
- $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , false );
1665
+ $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , false , $ dispositionAttachment );
1666
1666
$ mail ->addAttachment ($ attachment );
1667
1667
}
1668
1668
@@ -1680,7 +1680,7 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
1680
1680
}
1681
1681
1682
1682
if ($ isAttachment ) {
1683
- $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , $ emlParse );
1683
+ $ attachment = self ::downloadAttachment ($ dataInfo , $ params , $ partStructure , $ emlParse, $ dispositionAttachment );
1684
1684
$ mail ->addAttachment ($ attachment );
1685
1685
} else {
1686
1686
if (isset ($ params ['charset ' ]) && !empty (\trim ($ params ['charset ' ]))) {
@@ -1690,14 +1690,14 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
1690
1690
1691
1691
if (!empty ($ partStructure ->parts )) {
1692
1692
foreach ($ partStructure ->parts as $ subPartNum => $ subPartStructure ) {
1693
- $ not_attachment = (!isset ($ partStructure ->disposition ) || ' attachment ' !== $ partStructure -> disposition );
1693
+ $ not_attachment = (!isset ($ partStructure ->disposition ) || ! $ dispositionAttachment );
1694
1694
1695
1695
if (TYPEMESSAGE === $ partStructure ->type && 'RFC822 ' === $ partStructure ->subtype && $ not_attachment ) {
1696
1696
$ this ->initMailPart ($ mail , $ subPartStructure , $ partNum , $ markAsSeen );
1697
1697
} elseif (TYPEMULTIPART === $ partStructure ->type && 'ALTERNATIVE ' === $ partStructure ->subtype && $ not_attachment ) {
1698
1698
// https://github.com/barbushin/php-imap/issues/198
1699
1699
$ this ->initMailPart ($ mail , $ subPartStructure , $ partNum , $ markAsSeen );
1700
- } elseif ('RFC822 ' === $ partStructure ->subtype && isset ($ partStructure ->disposition ) && ' attachment ' === $ partStructure -> disposition ) {
1700
+ } elseif ('RFC822 ' === $ partStructure ->subtype && isset ($ partStructure ->disposition ) && $ dispositionAttachment ) {
1701
1701
//If it comes from am EML attachment, download each part separately as a file
1702
1702
$ this ->initMailPart ($ mail , $ subPartStructure , $ partNum .'. ' .($ subPartNum + 1 ), $ markAsSeen , true );
1703
1703
} else {
0 commit comments