You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When parsing an email with HTML content inside a multipart/related container, the content is incorrectly recognized as an attachment rather than being parsed as the email's HTML body.
Used config
The default config.
Code to Reproduce
Use the following raw message:
Return-Path: <[email protected]>
Date: Thu, 20 Feb 2025 03:44:22 +0100 (CET)
From: [email protected]To: [email protected], [email protected]Message-ID: <[email protected]>
Subject: html body in multipart related container is parsed as attachment
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_255_1307735605.1740019462622"------=_Part_255_1307735605.1740019462622Content-Type: multipart/related;
boundary="----=_Part_256_1484807935.1740019462623"------=_Part_256_1484807935.1740019462623Content-Type: text/html;charset=UTF-8Content-Transfer-Encoding: quoted-printable
<!DOCTYPE html>
<html>
<head>
<style>
p {font-family: "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;font-size: 13px; }</style>
</head>
<body>
<p>
This is a message in a multipart related container
</p>
</body>
</html>
------=_Part_256_1484807935.1740019462623--------=_Part_255_1307735605.1740019462622--
Use the following PHP test case:
publicfunctiontestIssueEmail() {
$filename = implode(DIRECTORY_SEPARATOR, [__DIR__, "..", "messages", "the-raw-message.eml"]);
$message = Message::fromFile($filename);
self::assertNotEmpty($message->getHTMLBody());
self::assertStringContainsString("This is a message in a multipart related container", $message->getHTMLBody());
self::assertCount(0, $message->getAttachments());
}
Execute the test and it will fail.
Expected behavior
The HTML content inside the multipart/related container should be correctly identified and parsed as the email's HTML body, not as an attachment.
Desktop:
OS: Manjaro
PHP: 8.4
laravel-imap version 6.2.0
Additional context:
In the example above, the email contains only HTML content, so the use of multipart/related is technically unnecessary. However, this container is often automatically generated by mail systems (e.g., JavaMail) when sending HTML content, even if there are no inline resources (like images or stylesheets) to relate.
The text was updated successfully, but these errors were encountered:
If I revert change commited in commit fad09ad and return line 116 in Struture.php to original
return $this->detectParts($boundary, $body, $part_number);
his example mail returns a body
So it seems PR for issue #455 may be affecting this too
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When parsing an email with HTML content inside a
multipart/related
container, the content is incorrectly recognized as an attachment rather than being parsed as the email's HTML body.Used config
The default config.
Code to Reproduce
Expected behavior
The HTML content inside the
multipart/related
container should be correctly identified and parsed as the email's HTML body, not as an attachment.Desktop:
Additional context:
The text was updated successfully, but these errors were encountered: