-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
getBodyHtml only returns first part of Mail #452
Comments
Hi, would you be able to reproduce the bug in a test case please? |
Hi, I'm not so sure what you need from me. Can you explain a little more please? Thanks. |
Would you be so kind to create a Pull-Request redacting a test case that uses your message to expose the bug you found? For example, this test case was redacted to reproduce a bug in handling GBK charset: Lines 1052 to 1059 in 208a29f
|
Sorry, I'm completely new to Github. I have no Idea how I am supposed to do that. |
Hi, I've created the pull request #454 . If I've missed something please let me know. Kind regards |
I've a message that return a blank html, it has 2 attachments. Does this help? |
Easy to reproduce: I fixed it with the method: private function getAllHtml(\Ddeboer\Imap\Message|\Ddeboer\Imap\MessageInterface $message)
{
$iterator = new \RecursiveIteratorIterator($message, \RecursiveIteratorIterator::SELF_FIRST);
$htmlParts = [];
foreach ($iterator as $part) {
if ($message::SUBTYPE_HTML === $part->getSubtype()) {
$htmlParts[] = $part->getDecodedContent();
}
}
if (count($htmlParts) === 1) {
return $htmlParts[0];
}
if (count($htmlParts) > 1) {
$newDom = new DOMDocument();
$newBody = '';
$newDom->loadHTML(mb_convert_encoding(implode('', $htmlParts), 'HTML-ENTITIES', 'UTF-8'));
$bodyTags = $newDom->getElementsByTagName('body');
foreach ($bodyTags as $body) {
foreach ($body->childNodes as $node) {
$newBody .= $newDom->saveHTML($node);
}
}
$newDom = new DOMDocument();
$newDom->loadHTML(mb_convert_encoding($newBody, 'HTML-ENTITIES', 'UTF-8'));
return $newDom->saveHTML();
}
// If message has no parts and is HTML, return content of message itself.
if ($message::SUBTYPE_HTML === $this->getSubtype()) {
return $this->getDecodedContent();
}
return null;
} Merge body tags: https://stackoverflow.com/questions/60163537/save-multiple-html-bodies-as-one-using-domdocument |
@arwinvdv would you be so kind to propose a PR with your fix? |
Hi,
we've noticed the following bug:
In some cases
$message->getBodyHtml()
only returns the first part of a multipart/mixed message. The Sender (or Apple) has inserted inline Images between multiple HTML Parts. It is possible to receive all attachments using$message->getAttachments()
(even though they aren't really inline).The rawMessage is attached (I've shortened the base64 decoded attachments):
rawMessage.txt
Kind regards
Kevin
The text was updated successfully, but these errors were encountered: