Skip to content

Commit 9db51fe

Browse files
author
Rubtsov Pavel
committed
making into disposition string to lowercase
1 parent 8e2f620 commit 9db51fe

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/PhpImap/Mailbox.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1250,9 +1250,9 @@ public function getMail(int $mailId, bool $markAsSeen = true): IncomingMail
12501250
*
12511251
* @return IncomingMailAttachment $attachment
12521252
*/
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
12541254
{
1255-
if ('RFC822' == $partStructure->subtype && isset($partStructure->disposition) && 'attachment' == $partStructure->disposition) {
1255+
if ('RFC822' == $partStructure->subtype && isset($partStructure->disposition) && $dispositionAttachment) {
12561256
$fileName = \strtolower($partStructure->subtype).'.eml';
12571257
} elseif ('ALTERNATIVE' == $partStructure->subtype) {
12581258
$fileName = \strtolower($partStructure->subtype).'.eml';
@@ -1659,10 +1659,10 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
16591659
}
16601660

16611661
// 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) {
16631663
// Although we are downloading each part separately, we are going to download the EML to a single file
16641664
//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);
16661666
$mail->addAttachment($attachment);
16671667
}
16681668

@@ -1680,7 +1680,7 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
16801680
}
16811681

16821682
if ($isAttachment) {
1683-
$attachment = self::downloadAttachment($dataInfo, $params, $partStructure, $emlParse);
1683+
$attachment = self::downloadAttachment($dataInfo, $params, $partStructure, $emlParse, $dispositionAttachment);
16841684
$mail->addAttachment($attachment);
16851685
} else {
16861686
if (isset($params['charset']) && !empty(\trim($params['charset']))) {
@@ -1690,14 +1690,14 @@ protected function initMailPart(IncomingMail $mail, object $partStructure, $part
16901690

16911691
if (!empty($partStructure->parts)) {
16921692
foreach ($partStructure->parts as $subPartNum => $subPartStructure) {
1693-
$not_attachment = (!isset($partStructure->disposition) || 'attachment' !== $partStructure->disposition);
1693+
$not_attachment = (!isset($partStructure->disposition) || !$dispositionAttachment);
16941694

16951695
if (TYPEMESSAGE === $partStructure->type && 'RFC822' === $partStructure->subtype && $not_attachment) {
16961696
$this->initMailPart($mail, $subPartStructure, $partNum, $markAsSeen);
16971697
} elseif (TYPEMULTIPART === $partStructure->type && 'ALTERNATIVE' === $partStructure->subtype && $not_attachment) {
16981698
// https://github.com/barbushin/php-imap/issues/198
16991699
$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) {
17011701
//If it comes from am EML attachment, download each part separately as a file
17021702
$this->initMailPart($mail, $subPartStructure, $partNum.'.'.($subPartNum + 1), $markAsSeen, true);
17031703
} else {

0 commit comments

Comments
 (0)