Skip to content

Empty HTML body, content is considered as attachment #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
digiwirtual opened this issue May 10, 2025 · 2 comments
Open

Empty HTML body, content is considered as attachment #578

digiwirtual opened this issue May 10, 2025 · 2 comments
Labels
bug Something isn't working More information required Further information is requested validating

Comments

@digiwirtual
Copy link

digiwirtual commented May 10, 2025

Wrong parsing parts of email, result is empty body and one attachment with wrong parsed html content.

Used config
Image

Problematic email
0-email.zip

  1. Initially, in Structure::parsePart, everything is processed correctly. One part is detected from the email, which is valid – see the output of $parts. Image
  2. However, at line 118, the condition is skipped, and the valid variable $parts is discarded. The code continues at line 123, where the body is re-parsed using the class Part. The result is an invalid $part. Image
  3. The final result is that the Message object does not contain $bodies, but it does contain an attachment where $part is invalid. Image
  4. The solution lies at line 118 – if the valid result ($parts) were not discarded, the issue would be resolved. Image

The actual bug seems to be here, but you'll need to determine that yourself, as I don't have perfect knowledge of the email structure. Maybe other parts of the email should not be considered as empty so condition will work...

@digiwirtual digiwirtual changed the title Empty HTML body, content is considered as attachement Empty HTML body, content is considered as attachment May 10, 2025
@Webklex Webklex added More information required Further information is requested bug Something isn't working validating labels May 27, 2025
@mrhewitt
Copy link

Also related to #582

Looking at your example it has same structure as #580 , a single part inside a multipart structure, PR for issue #455 altered the line you highlight, the original code was:

return $this->detectParts($boundary, $body, $part_number);

Reverting back to this (i.e revert commit fad09ad) results in your body being returned correctly.

Unfortunately #455 did not contain any example Mime content so I am not sure what structure he had to require skipping parts if only one is detected inside a mulitpart block, but it seems to be causing some ripples of issues

FYI, I mention I am working on a PR but it was fix for attachments, I didnt realize how extensive issue was and wont help here .

I am not unconvinced perhaps content in issue #455 is exception rather than the rule.

@radek-hill
Copy link

Idea: it can be implemented as feature flag, which will be enabled only for testing purpose or peaple having issue like me. In this case it wount affect any working implementation and after some time, when we will have enought experience with enabled feature, can be removed and fixed permanently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working More information required Further information is requested validating
Projects
None yet
Development

No branches or pull requests

4 participants