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

Body not recognized

Open raxmans opened this issue 9 months ago • 4 comments

Describe the bug I have an email, where I check, what type, HTML or Text $text_body = $message->hasTextBody(); $html_body = $message->hasHTMLBody();

Used config Please provide the used config, if you are not using the package default config.

Code to Reproduce The troubling code section which produces the reported bug.

	    	$text_body = $message->hasTextBody();
	    	$html_body = $message->hasHTMLBody();
echo "$text_body";
echo "$html_body";

Expected behavior all are empty and not one of them is 1

Screenshots If applicable, add screenshots to help explain your problem.

Image

Desktop / Server (please complete the following information):

  • OS: windows server 2019
  • PHP: 8.3.17
  • Version
  • Provider Outlook, Exchange

Additional context Add any other context about the problem here. i think it has to do with the marked in the screenshot

raxmans avatar Mar 13 '25 11:03 raxmans

As a result, I can't get the body of the message.

raxmans avatar Mar 13 '25 11:03 raxmans

maybe related to #562

Pascal76 avatar Mar 13 '25 11:03 Pascal76

Have the same issue. This is triggered by Emails (like from apple mail), which are very simple plain text mails. Many mail programs create a multipart-message with a separate part for plain text, even if there is only plan text. apple mail (and maybe others) create a mail with the content-type in the header like this

"Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 (3826.500.181.1.5)) X-Mailer: Apple Mail (2.3826.500.181.1.5)

simpleplaintextcontent"

These emails content is empty with php-imap. The native php extension shows the content (retrievable from structure). Even more strange: If you receive the raw email, it is also empty.

Diving into php-imaps code. the function ->content( in /php-imap/src/Connection/Protocols/ImapProtocol.php: 882 public function content(int|array $uids, string $rfc = "RFC822", int|string $uid = IMAP::ST_UID): Response { gets data from the ->fetch( function. For the body part of these emails. Fetch retrieves an empty result

The code of the fetch function, using imap protocol is too complex for my abilities. please help. I can send one of these emails to a testing address

dwrana avatar Apr 21 '25 07:04 dwrana

Could also be related to my issue #582

You mention mail client provides a structure with a single plain text block inside a multipart block , I have found a change committed in #455 causes it to ignore parts when it finds only a single part inside a multipart structure. Seems your issue may be caused by this .

mrhewitt avatar May 29 '25 08:05 mrhewitt