php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Count of attachments is wrong

Open TonyMarston opened this issue 1 year ago • 5 comments

Describe the bug When I have an email that contains both plain text and an HTML body the attachment count shows up as 1 instead of zero. When I iterate through the attachments I notice that the non-attachment does not contain the text: 'Content-Disposition: attachment;'

When I examine the email source I see the following entries: Content-Type: multipart/mixed; Content-Type: multipart/alternative; Content-Type: text/plain; Content-Type: text/html;

The non-attachment showed the contents of the multipart/mixed entry;

A real attachment contains the lines: Content-Type: application/pdf; name="blahpdf" Content-Disposition: attachment;

Expected behavior I expect the count of attachments to be accurate.

Suggested Fix I stepped through the code and found this at line 288 in part.php if (($this->subtype == null || in_array((strtolower($this->subtype)), ["plain", "html"])) && $this->filename == null && $this->name == null) { I changed it to ["plain", "html", "mixed"] and this fixed the problem.

TonyMarston avatar Jun 03 '23 14:06 TonyMarston

I've just started using this module, and what is really annoying is that I get different attachment counts each time I run the same script on the same message!

kolonuk avatar Jun 21 '23 14:06 kolonuk

Hi @TonyMarston,

Thanks a lot for reporting this issue. I really appreciate it! However, in order to help you out, it would be great if you could provide an anonymized version of the problematic message. Without that, it's quite tough for me to debug the issue accurately.

If you're using an older version of the library, I recommend updating to the latest version and giving it another shot. There's a chance that the problem might have already been fixed in the newer release. It might also be related to https://github.com/Webklex/php-imap/issues/418

Once again, thanks for taking the time and effort to make this library better! If you have any more questions or need further assistance, feel free to let me know.

Best regards and happy coding!

Webklex avatar Jun 23 '23 14:06 Webklex

Attached is the source of an email message which is reported as having 1 attachment but actually has none.

Tony Marston

http://www.tonymarston.net http://www.tonymarston.net http://www.radicore.org http://www.radicore.org

From: Webklex @.> Sent: Friday, June 23, 2023 4:00 PM To: Webklex/php-imap @.> Cc: Tony Marston @.>; Mention @.> Subject: Re: [Webklex/php-imap] Count of attachments is wrong (Issue #412)

Hi @TonyMarston https://github.com/TonyMarston , Thanks a lot for reporting this issue. I really appreciate it! However, in order to help you out, it would be great if you could provide an anonymized version of the problematic message. Without that, it's quite tough for me to debug the issue accurately. If you're using an older version of the library, I recommend updating to the latest version and giving it another shot. There's a chance that the problem might have already been fixed in the newer release. It might also be related to #418 https://github.com/Webklex/php-imap/issues/418 Once again, thanks for taking the time and effort to make this library better! If you have any more questions or need further assistance, feel free to let me know. Best regards and happy coding! — Reply to this email directly, view it on GitHub https://github.com/Webklex/php-imap/issues/412#issuecomment-1604405257 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADRYNOEVYQGED7XBUZGGGMTXMWVNJANCNFSM6AAAAAAYZKL4EM . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ADRYNOAIJUTPDILOYIJSUKLXMWVNJA5CNFSM6AAAAAAYZKL4EOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTS7UFEAS.gif Message ID: @.*** @.***> >

TonyMarston avatar Jun 23 '23 17:06 TonyMarston

Hi @TonyMarston , many thanks for the quick followup. Unfortunately I'm unable to replicate the behavior (see the referenced commit above).

Best regards and happy coding,

Webklex avatar Jun 23 '23 19:06 Webklex