php-imap-client: Sent from macOS Mail, Inline attachment breaks email

Hi

We noticed that if a user drops in an attachment inside an email (at least on Apple Mail), -like in between the text, then when opening it in (php-imap-client) webmail the mail is truncated just at the attachment, none of the content, text and so after this point is there.

The issue is probably in the get_part() function, here:

// multipart
if ($structure->type == 1) {
	foreach ($structure->parts as $index => $subStruct) {
		$prefix = "";
		if ($partNumber) {
			$prefix = $partNumber . ".";
		}
		$data = $this->get_part($imap, $uid, $mimetype, $subStruct, $prefix . ($index + 1));
		if ($data) {
			return $data;
		}
	}
}

If I change to below, the whole email is there, but now the HTML formatting is lost:

// multipart
if ($structure->type == 1) {
	foreach ($structure->parts as $index => $subStruct) {
		$data = $this->get_part($imap, $uid, $mimetype, $subStruct, $partNumber);
		if ($data) {
			return $data;
		}
	}
}

The attachments is there so no problem with that. Is only that either mail is truncated, or HTML formatting is lost, -for all emails, also without attachments.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (1 by maintainers)

Most upvoted comments

Thanks. Let me know I’ll do some digging aswell