From c6ce324e2dff3463e02bf78ceb83792627f56cff Mon Sep 17 00:00:00 2001 From: Eugene Eroshkin Date: Wed, 3 Jul 2019 17:55:31 +0300 Subject: [PATCH 01/16] Fixes "decodeMimeStr() Can not decode an empty" error when mail has no subject. --- src/PhpImap/Mailbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 7048761f..86b8e26e 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -668,7 +668,7 @@ public function getMailsInfo(array $mailsIds) $mails = $this->imap('fetch_overview', [implode(',', $mailsIds), (SE_UID == $this->imapSearchOption) ? FT_UID : 0]); if (\is_array($mails) && \count($mails)) { foreach ($mails as &$mail) { - if (isset($mail->subject)) { + if (!empty($mail->subject)) { $mail->subject = $this->decodeMimeStr($mail->subject, $this->getServerEncoding()); } if (isset($mail->from) and !empty($mail->from)) { From 01a3ac4b22e4050db2103ce9d96fc3e6709436c2 Mon Sep 17 00:00:00 2001 From: Eugene Eroshkin Date: Wed, 3 Jul 2019 18:36:51 +0300 Subject: [PATCH 02/16] Code review update. --- src/PhpImap/Mailbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 86b8e26e..7f2e77de 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -668,7 +668,7 @@ public function getMailsInfo(array $mailsIds) $mails = $this->imap('fetch_overview', [implode(',', $mailsIds), (SE_UID == $this->imapSearchOption) ? FT_UID : 0]); if (\is_array($mails) && \count($mails)) { foreach ($mails as &$mail) { - if (!empty($mail->subject)) { + if (isset($mail->subject) and !empty($mail->subject)) { $mail->subject = $this->decodeMimeStr($mail->subject, $this->getServerEncoding()); } if (isset($mail->from) and !empty($mail->from)) { From 65bdc1e2397a51d4774d349b0a0ad9c811bcc11b Mon Sep 17 00:00:00 2001 From: sharevb Date: Wed, 10 Jul 2019 12:59:56 +0200 Subject: [PATCH 03/16] Flatten mail parts before parsing Handle Gmail multipart/related way of structuring mail with attachments --- src/PhpImap/Mailbox.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 7f2e77de..4bf69af9 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -902,6 +902,27 @@ public function getMailHeader($mailId) return $header; } + /** + * taken from https://www.electrictoolbox.com/php-imap-message-parts/ + */ + function flattenParts( $messageParts, $flattenedParts = array(), $prefix = '', $index = 1, $fullPrefix = true ) { + foreach ( $messageParts as $part ) { + $flattenedParts[ $prefix . $index ] = $part; + if ( isset( $part->parts ) ) { + if ( $part->type == 2 ) { + $flattenedParts = $this->flattenParts( $part->parts, $flattenedParts, $prefix . $index . '.', 0, false ); + } elseif ( $fullPrefix ) { + $flattenedParts = $this->flattenParts( $part->parts, $flattenedParts, $prefix . $index . '.' ); + } else { + $flattenedParts = $this->flattenParts( $part->parts, $flattenedParts, $prefix ); + } + unset( $flattenedParts[ $prefix . $index ]->parts ); + } + $index ++; + } + return $flattenedParts; + } + /** * Get mail data. * @@ -920,9 +941,9 @@ public function getMail($mailId, $markAsSeen = true) if (empty($mailStructure->parts)) { $this->initMailPart($mail, $mailStructure, 0, $markAsSeen); } else { - foreach ($mailStructure->parts as $partNum => $partStructure) { - $this->initMailPart($mail, $partStructure, $partNum + 1, $markAsSeen); - } + foreach ( $this->flattenParts( $mailStructure->parts ) as $partNum => $partStructure ) { + $this->initMailPart( $mail, $partStructure, $partNum, $markAsSeen ); + } } return $mail; From b9517719071a55793396c63899b37d3780ffb81b Mon Sep 17 00:00:00 2001 From: sharevb Date: Wed, 10 Jul 2019 13:20:39 +0200 Subject: [PATCH 04/16] Fix Coding Standards --- src/PhpImap/Mailbox.php | 46 +++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 4bf69af9..4412f2d3 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -903,25 +903,27 @@ public function getMailHeader($mailId) } /** - * taken from https://www.electrictoolbox.com/php-imap-message-parts/ - */ - function flattenParts( $messageParts, $flattenedParts = array(), $prefix = '', $index = 1, $fullPrefix = true ) { - foreach ( $messageParts as $part ) { - $flattenedParts[ $prefix . $index ] = $part; - if ( isset( $part->parts ) ) { - if ( $part->type == 2 ) { - $flattenedParts = $this->flattenParts( $part->parts, $flattenedParts, $prefix . $index . '.', 0, false ); - } elseif ( $fullPrefix ) { - $flattenedParts = $this->flattenParts( $part->parts, $flattenedParts, $prefix . $index . '.' ); - } else { - $flattenedParts = $this->flattenParts( $part->parts, $flattenedParts, $prefix ); - } - unset( $flattenedParts[ $prefix . $index ]->parts ); - } - $index ++; - } - return $flattenedParts; - } + * taken from https://www.electrictoolbox.com/php-imap-message-parts/. + */ + public function flattenParts($messageParts, $flattenedParts = [], $prefix = '', $index = 1, $fullPrefix = true) + { + foreach ($messageParts as $part) { + $flattenedParts[$prefix.$index] = $part; + if (isset($part->parts)) { + if (2 == $part->type) { + $flattenedParts = $this->flattenParts($part->parts, $flattenedParts, $prefix.$index.'.', 0, false); + } elseif ($fullPrefix) { + $flattenedParts = $this->flattenParts($part->parts, $flattenedParts, $prefix.$index.'.'); + } else { + $flattenedParts = $this->flattenParts($part->parts, $flattenedParts, $prefix); + } + unset($flattenedParts[$prefix.$index]->parts); + } + ++$index; + } + + return $flattenedParts; + } /** * Get mail data. @@ -941,9 +943,9 @@ public function getMail($mailId, $markAsSeen = true) if (empty($mailStructure->parts)) { $this->initMailPart($mail, $mailStructure, 0, $markAsSeen); } else { - foreach ( $this->flattenParts( $mailStructure->parts ) as $partNum => $partStructure ) { - $this->initMailPart( $mail, $partStructure, $partNum, $markAsSeen ); - } + foreach ($this->flattenParts($mailStructure->parts) as $partNum => $partStructure) { + $this->initMailPart($mail, $partStructure, $partNum, $markAsSeen); + } } return $mail; From dd634bfd43f10aa73aad81fb171dce752cf8867a Mon Sep 17 00:00:00 2001 From: sharevb Date: Wed, 10 Jul 2019 13:29:57 +0200 Subject: [PATCH 05/16] Fix blank line --- src/PhpImap/Mailbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 4412f2d3..63213dfd 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -924,7 +924,7 @@ public function flattenParts($messageParts, $flattenedParts = [], $prefix = '', return $flattenedParts; } - + /** * Get mail data. * From 363c14ab18b73fb99c27c16b157fc4f8bd77570d Mon Sep 17 00:00:00 2001 From: Reshat Belyalov Date: Thu, 11 Jul 2019 17:27:04 +0300 Subject: [PATCH 06/16] trim $to->personal field before decoding --- src/PhpImap/Mailbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 7f2e77de..54796e51 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -865,7 +865,7 @@ public function getMailHeader($mailId) foreach ($head->to as $to) { if (!empty($to->mailbox) && !empty($to->host)) { $toEmail = strtolower($to->mailbox.'@'.$to->host); - $toName = (isset($to->personal) and !empty($to->personal)) ? $this->decodeMimeStr($to->personal, $this->getServerEncoding()) : null; + $toName = (isset($to->personal) and !empty(trim($to->personal))) ? $this->decodeMimeStr($to->personal, $this->getServerEncoding()) : null; $toStrings[] = $toName ? "$toName <$toEmail>" : $toEmail; $header->to[$toEmail] = $toName; } From a31f8dccfa8f98cdbbe627c8cba3331eae34697b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 13:20:34 +0200 Subject: [PATCH 07/16] Issue #359: Updated code logic for CC, BCC, REPLY-TO to same as for TO --- src/PhpImap/Mailbox.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 4f8d59dc..5ff6d3db 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -876,7 +876,10 @@ public function getMailHeader($mailId) if (isset($head->cc)) { foreach ($head->cc as $cc) { if (!empty($cc->mailbox) && !empty($cc->host)) { - $header->cc[strtolower($cc->mailbox.'@'.$cc->host)] = (isset($cc->personal) and !empty($cc->personal)) ? $this->decodeMimeStr($cc->personal, $this->getServerEncoding()) : null; + $ccEmail = strtolower($cc->mailbox.'@'.$cc->host); + $ccName = (isset($cc->personal) and !empty(trim($cc->personal))) ? $this->decodeMimeStr($cc->personal, $this->getServerEncoding()) : null; + $ccStrings[] = $ccName ? "$ccName <$ccEmail>" : $ccEmail; + $header->cc[$ccEmail] = $ccName; } } } @@ -884,14 +887,22 @@ public function getMailHeader($mailId) if (isset($head->bcc)) { foreach ($head->bcc as $bcc) { if (!empty($bcc->mailbox) && !empty($bcc->host)) { - $header->bcc[strtolower($bcc->mailbox.'@'.$bcc->host)] = (isset($bcc->personal) and !empty($bcc->personal)) ? $this->decodeMimeStr($bcc->personal, $this->getServerEncoding()) : null; + $bccEmail = strtolower($bcc->mailbox.'@'.$bcc->host); + $bccName = (isset($bcc->personal) and !empty(trim($bcc->personal))) ? $this->decodeMimeStr($bcc->personal, $this->getServerEncoding()) : null; + $bccStrings[] = $bccName ? "$bccName <$bccEmail>" : $bccEmail; + $header->bcc[$bccEmail] = $bccName; } } } if (isset($head->reply_to)) { foreach ($head->reply_to as $replyTo) { - $header->replyTo[strtolower($replyTo->mailbox.'@'.$replyTo->host)] = (isset($replyTo->personal) and !empty($replyTo->personal)) ? $this->decodeMimeStr($replyTo->personal, $this->getServerEncoding()) : null; + if (!empty($replyTo->mailbox) && !empty($replyTo->host)) { + $replyToEmail = strtolower($replyTo->mailbox.'@'.$replyTo->host); + $replyToName = (isset($replyTo->personal) and !empty(trim($replyTo->personal))) ? $this->decodeMimeStr($replyTo->personal, $this->getServerEncoding()) : null; + $replyToStrings[] = $replyToName ? "$replyToName <$replyToEmail>" : $replyToEmail; + $header->replyTo[$replyToEmail] = $replyToName; + } } } From 6897e9bfdeff04c2f95584effc181654f1075b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 15:24:46 +0200 Subject: [PATCH 08/16] Fixed coding standard --- src/PhpImap/Mailbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 5ff6d3db..33d6f96c 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -902,7 +902,7 @@ public function getMailHeader($mailId) $replyToName = (isset($replyTo->personal) and !empty(trim($replyTo->personal))) ? $this->decodeMimeStr($replyTo->personal, $this->getServerEncoding()) : null; $replyToStrings[] = $replyToName ? "$replyToName <$replyToEmail>" : $replyToEmail; $header->replyTo[$replyToEmail] = $replyToName; - } + } } } From d26d8e4444eec169fae1e16aaffcb99b2e8d8160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 15:35:42 +0200 Subject: [PATCH 09/16] Issue #360: Improved usage of property $imapPath --- src/PhpImap/Mailbox.php | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 33d6f96c..76103102 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -368,7 +368,7 @@ public function decodeStringFromUtf7ImapToUtf8($str) public function switchMailbox($imapPath) { $this->imapPath = $imapPath; - $this->imap('reopen', $this->imapPath); + $this->imap('reopen', $this->getCombinedPath($imapPath, true)); } protected function initImapStreamWithRetry() @@ -439,7 +439,7 @@ public function checkMailbox() */ public function createMailbox($name) { - $this->imap('createmailbox', $this->imapPath.$this->getPathDelimiter().$name); + $this->imap('createmailbox', $this->getCombinedPath($name)); } /** @@ -449,7 +449,7 @@ public function createMailbox($name) */ public function deleteMailbox($name) { - $this->imap('deletemailbox', $this->imapPath.$this->getPathDelimiter().$name); + $this->imap('deletemailbox', $this->getCombinedPath($name)); } /** @@ -460,7 +460,7 @@ public function deleteMailbox($name) */ public function renameMailbox($oldName, $newName) { - $this->imap('renamemailbox', [$this->imapPath.$this->getPathDelimiter().$oldName, $this->imapPath.$this->getPathDelimiter().$newName]); + $this->imap('renamemailbox', [$this->getCombinedPath($oldName), $this->getCombinedPath($newName)]); } /** @@ -1316,7 +1316,7 @@ public function getSubscribedMailboxes($search = '*') */ public function subscribeMailbox($mailbox) { - $this->imap('subscribe', $this->imapPath.$this->getPathDelimiter().$mailbox); + $this->imap('subscribe', $this->getCombinedPath($mailbox)); } /** @@ -1328,7 +1328,7 @@ public function subscribeMailbox($mailbox) */ public function unsubscribeMailbox($mailbox) { - $this->imap('unsubscribe', $this->imapPath.$this->getPathDelimiter().$mailbox); + $this->imap('unsubscribe', $this->getCombinedPath($mailbox)); } /** @@ -1386,4 +1386,28 @@ public function imap($methodShortName, $args = [], $prependConnectionAsFirstArg return $result; } + + /** + * Combine Subfolder or Folder to the connection. + * + * Have the imapPath a folder added to the connection info, then will the $folder added as subfolder. + * If the parameter $absolute TRUE, then will the connection new builded only with this folder as root element. + * + * @param string $folder Folder, the will added to the path + * @param bool $absolute Add folder as root element to the connection and remove all other from this + * @return string Return the new path + */ + protected function getCombinedPath(string $folder, bool $absolute = false) + { + if (!empty($folder)) { + if ("}" === substr($this->imapPath, -1) || true === $absolute) { + $posConnectionDefinitionEnd = strpos($this->imapPath, "}"); + return substr($this->imapPath, 0, $posConnectionDefinitionEnd + 1) . $folder; + } else { + return $this->imapPath . $this->getPathDelimiter() . $folder; + } + } + + return $this->imapPath; + } } From 33c85f0c55a28010a3c79a6ab12ebd73a9c87cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 15:39:49 +0200 Subject: [PATCH 10/16] Fixed coding standards --- src/PhpImap/Mailbox.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 76103102..ded7ede3 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -1393,9 +1393,10 @@ public function imap($methodShortName, $args = [], $prependConnectionAsFirstArg * Have the imapPath a folder added to the connection info, then will the $folder added as subfolder. * If the parameter $absolute TRUE, then will the connection new builded only with this folder as root element. * - * @param string $folder Folder, the will added to the path - * @param bool $absolute Add folder as root element to the connection and remove all other from this - * @return string Return the new path + * @param string $folder Folder, the will added to the path + * @param bool $absolute Add folder as root element to the connection and remove all other from this + * + * @return string Return the new path */ protected function getCombinedPath(string $folder, bool $absolute = false) { From c440808e2fe166daadfc9203d59ed12abeb86b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 15:53:58 +0200 Subject: [PATCH 11/16] Fixed coding standards --- src/PhpImap/Mailbox.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index ded7ede3..17c9bb5c 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -795,7 +795,7 @@ public function getQuotaUsage($quota_root = 'INBOX') * Get raw mail data. * * @param $msgId - * @param bool $markAsSeen Mark the email as seen, when set to true + * @param bool $markAsSeen Mark the email as seen, when set to true */ public function getRawMail($msgId, $markAsSeen = true) { @@ -940,7 +940,7 @@ public function flattenParts($messageParts, $flattenedParts = [], $prefix = '', * Get mail data. * * @param $mailId - * @param bool $markAsSeen Mark the email as seen, when set to true + * @param bool $markAsSeen Mark the email as seen, when set to true * * @return IncomingMail */ @@ -1013,9 +1013,10 @@ protected function initMailPart(IncomingMail $mail, $partStructure, $partNum, $m } // Do NOT parse attachments, when getAttachmentsIgnore() is true - if ($this->getAttachmentsIgnore() && - (TYPEMULTIPART !== $partStructure->type && - (TYPETEXT !== $partStructure->type || !\in_array(strtolower($partStructure->subtype), ['plain', 'html'])))) { + if ($this->getAttachmentsIgnore() + && (TYPEMULTIPART !== $partStructure->type + && (TYPETEXT !== $partStructure->type || !\in_array(strtolower($partStructure->subtype), ['plain', 'html']))) + ) { return false; } From 4fceb0ba291ec54f502437f81c5de4d67fe0882f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 16:25:09 +0200 Subject: [PATCH 12/16] Fixed coding standards --- src/PhpImap/Mailbox.php | 48 ++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 17c9bb5c..94ae4128 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -622,7 +622,8 @@ public function markMailsAsImportant(array $mailId) /** * Causes a store to add the specified flag to the flags set for the mails in the specified sequence. * - * @param string $flag which you can set are \Seen, \Answered, \Flagged, \Deleted, and \Draft as defined by RFC2060 + * @param array $mailsIds Array of mail IDs + * @param string $flag Which you can set are \Seen, \Answered, \Flagged, \Deleted, and \Draft as defined by RFC2060 */ public function setFlag(array $mailsIds, $flag) { @@ -630,9 +631,10 @@ public function setFlag(array $mailsIds, $flag) } /** - * Cause a store to delete the specified flag to the flags set for the mails in the specified sequence. + * Causes a store to delete the specified flag to the flags set for the mails in the specified sequence. * - * @param string $flag which you can set are \Seen, \Answered, \Flagged, \Deleted, and \Draft as defined by RFC2060 + * @param array $mailsIds Array of mail IDs + * @param string $flag Which you can delete are \Seen, \Answered, \Flagged, \Deleted, and \Draft as defined by RFC2060 */ public function clearFlag(array $mailsIds, $flag) { @@ -661,7 +663,7 @@ public function clearFlag(array $mailsIds, $flag) * seen - this mail is flagged as already read * draft - this mail is flagged as being a draft * - * @return array + * @return array $mailsIds Array of mail IDs */ public function getMailsInfo(array $mailsIds) { @@ -730,8 +732,8 @@ public function getMailboxInfo() * SORTCC - mailbox in first cc address * SORTSIZE - size of mail in octets * - * @param int $criteria - * @param bool $reverse + * @param int $criteria Sorting criteria (eg. SORTARRIVAL) + * @param bool $reverse Sort reverse or not * @param string $searchCriteria See http://php.net/imap_search for a complete list of available criteria * * @return array Mails ids @@ -754,7 +756,7 @@ public function countMails() /** * Retrieve the quota settings per user. * - * @param string Should normally be in the form of which mailbox (i.e. INBOX) + * @param string $quota_root Should normally be in the form of which mailbox (i.e. INBOX) * * @return array */ @@ -766,7 +768,7 @@ protected function getQuota($quota_root = 'INBOX') /** * Return quota limit in KB. * - * @param string Should normally be in the form of which mailbox (i.e. INBOX) + * @param string $quota_root Should normally be in the form of which mailbox (i.e. INBOX) * * @return int */ @@ -780,7 +782,7 @@ public function getQuotaLimit($quota_root = 'INBOX') /** * Return quota usage in KB. * - * @param string Should normally be in the form of which mailbox (i.e. INBOX) + * @param string $quota_root Should normally be in the form of which mailbox (i.e. INBOX) * * @return int FALSE in the case of call failure */ @@ -794,8 +796,10 @@ public function getQuotaUsage($quota_root = 'INBOX') /** * Get raw mail data. * - * @param $msgId - * @param bool $markAsSeen Mark the email as seen, when set to true + * @param integer $msgId ID of the message + * @param bool $markAsSeen Mark the email as seen, when set to true + * + * @return string Message of the fetched body */ public function getRawMail($msgId, $markAsSeen = true) { @@ -810,7 +814,7 @@ public function getRawMail($msgId, $markAsSeen = true) /** * Get mail header. * - * @param $mailId + * @param integer $mailId ID of the message * * @return IncomingMailHeader * @@ -939,8 +943,8 @@ public function flattenParts($messageParts, $flattenedParts = [], $prefix = '', /** * Get mail data. * - * @param $mailId - * @param bool $markAsSeen Mark the email as seen, when set to true + * @param integer $mailId ID of the mail + * @param bool $markAsSeen Mark the email as seen, when set to true * * @return IncomingMail */ @@ -1013,8 +1017,8 @@ protected function initMailPart(IncomingMail $mail, $partStructure, $partNum, $m } // Do NOT parse attachments, when getAttachmentsIgnore() is true - if ($this->getAttachmentsIgnore() - && (TYPEMULTIPART !== $partStructure->type + if ($this->getAttachmentsIgnore() + && (TYPEMULTIPART !== $partStructure->type && (TYPETEXT !== $partStructure->type || !\in_array(strtolower($partStructure->subtype), ['plain', 'html']))) ) { return false; @@ -1390,10 +1394,9 @@ public function imap($methodShortName, $args = [], $prependConnectionAsFirstArg /** * Combine Subfolder or Folder to the connection. - * * Have the imapPath a folder added to the connection info, then will the $folder added as subfolder. * If the parameter $absolute TRUE, then will the connection new builded only with this folder as root element. - * + * * @param string $folder Folder, the will added to the path * @param bool $absolute Add folder as root element to the connection and remove all other from this * @@ -1402,11 +1405,12 @@ public function imap($methodShortName, $args = [], $prependConnectionAsFirstArg protected function getCombinedPath(string $folder, bool $absolute = false) { if (!empty($folder)) { - if ("}" === substr($this->imapPath, -1) || true === $absolute) { - $posConnectionDefinitionEnd = strpos($this->imapPath, "}"); - return substr($this->imapPath, 0, $posConnectionDefinitionEnd + 1) . $folder; + if ('}' === substr($this->imapPath, -1) || true === $absolute) { + $posConnectionDefinitionEnd = strpos($this->imapPath, '}'); + + return substr($this->imapPath, 0, $posConnectionDefinitionEnd + 1).$folder; } else { - return $this->imapPath . $this->getPathDelimiter() . $folder; + return $this->imapPath.$this->getPathDelimiter().$folder; } } From 434baa793dc2cdc7cc5d574f287f0d5d3180b56a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 16:46:44 +0200 Subject: [PATCH 13/16] Fixed coding standards --- src/PhpImap/Mailbox.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 94ae4128..03c234ab 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -796,8 +796,8 @@ public function getQuotaUsage($quota_root = 'INBOX') /** * Get raw mail data. * - * @param integer $msgId ID of the message - * @param bool $markAsSeen Mark the email as seen, when set to true + * @param int $msgId ID of the message + * @param bool $markAsSeen Mark the email as seen, when set to true * * @return string Message of the fetched body */ @@ -814,7 +814,7 @@ public function getRawMail($msgId, $markAsSeen = true) /** * Get mail header. * - * @param integer $mailId ID of the message + * @param int $mailId ID of the message * * @return IncomingMailHeader * From 0ad68d31564f514277aadd9b8febca9697b93023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 16:54:47 +0200 Subject: [PATCH 14/16] Fixed coding standards --- src/PhpImap/Mailbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 03c234ab..bf7e7bce 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -943,8 +943,8 @@ public function flattenParts($messageParts, $flattenedParts = [], $prefix = '', /** * Get mail data. * - * @param integer $mailId ID of the mail - * @param bool $markAsSeen Mark the email as seen, when set to true + * @param int $mailId ID of the mail + * @param bool $markAsSeen Mark the email as seen, when set to true * * @return IncomingMail */ From 6d2ffddca726b497fa73e9f2c3f8340bec2d27ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 17:01:51 +0200 Subject: [PATCH 15/16] Fixed coding standards (removed trailing spaces) --- src/PhpImap/Mailbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index bf7e7bce..58b97b53 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -1396,10 +1396,10 @@ public function imap($methodShortName, $args = [], $prependConnectionAsFirstArg * Combine Subfolder or Folder to the connection. * Have the imapPath a folder added to the connection info, then will the $folder added as subfolder. * If the parameter $absolute TRUE, then will the connection new builded only with this folder as root element. - * + * * @param string $folder Folder, the will added to the path * @param bool $absolute Add folder as root element to the connection and remove all other from this - * + * * @return string Return the new path */ protected function getCombinedPath(string $folder, bool $absolute = false) From 9a68a67d3aad1719d83653eca7e2a280b5ba9e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=A4tzig?= Date: Sat, 13 Jul 2019 17:09:06 +0200 Subject: [PATCH 16/16] Fixed coding standards --- src/PhpImap/Mailbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 58b97b53..263965dd 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -798,7 +798,7 @@ public function getQuotaUsage($quota_root = 'INBOX') * * @param int $msgId ID of the message * @param bool $markAsSeen Mark the email as seen, when set to true - * + * * @return string Message of the fetched body */ public function getRawMail($msgId, $markAsSeen = true)