ddeboer / imap

Object-oriented, fully tested PHP IMAP library
MIT License
888 stars 253 forks source link

Method to get all text parts and complete text body #560

Closed arwinvdv closed 1 year ago

arwinvdv commented 1 year ago

I tested the library with a mail with 2 attachments send from an iPad. But I didn't get the right body because of multiple plain text parts.

I added the getCompleteBodyText function to get all plain text parts as one string.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 :tada:

Comparison is base (7ace12c) 95.10% compared to head (431b518) 95.12%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #560 +/- ## ============================================ + Coverage 95.10% 95.12% +0.02% - Complexity 364 365 +1 ============================================ Files 45 45 Lines 939 943 +4 ============================================ + Hits 893 897 +4 Misses 46 46 ``` | [Impacted Files](https://app.codecov.io/gh/ddeboer/imap/pull/560?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+de+Boer) | Coverage Δ | | |---|---|---| | [src/Message/AbstractMessage.php](https://app.codecov.io/gh/ddeboer/imap/pull/560?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+de+Boer#diff-c3JjL01lc3NhZ2UvQWJzdHJhY3RNZXNzYWdlLnBocA==) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

rudiedirkx commented 1 year ago

Shouldn't getAllContentsByType be called getAllContentsBySubtype since it checks for subtypes. I would use it to find the DELIVERY-STATUS AND RFC822 attachments, which are subtypes. Maybe it's too verbose, but more clear IMO.

Slamdunk commented 1 year ago

@rudiedirkx can you test this patch to see if it solves https://github.com/ddeboer/imap/issues/561?

rudiedirkx commented 1 year ago

@rudiedirkx can you test this patch to see if it solves #561?

It doesn't. It can't because the problem lies somewhere else, in 'attachment detection' in AbstractPart::lazyParseStructure() and/or AbstractPart::isAttachment(). It's not about finding the right part. That's already possible with new RecursiveIteratorIterator($message, RecursiveIteratorIterator::SELF_FIRST). That could be made much easier in this PR with a getAllPartsBy(Sub)type, but that's more for me than for this PR.

petraeus commented 4 months ago

Hello, can you return subtype SUBTYPE_RFC822 along with SUBTYPE_PLAIN in getCompleteBodyText message/delivery-status is a subtype used by gmail to return extended smtp error code