SSilence / php-imap-client

a easy solution for simple IMAP email access in php
MIT License
268 stars 136 forks source link

Sometimes email body is empty #203

Open qualityplatforms opened 6 years ago

qualityplatforms commented 6 years ago

Feature request or bug

bug

If a bug, what did you expect to happen?

get the body of the message

If a bug, what happened?

$mail->message->plain & $mail->message->html receives an null

If a bug, list steps to reproduce bugs.

The problem exist when i have an long conversation. After like 5 replies the mail receives nothing. I was using roundcube for replies.

If a bug, did you do these steps?

[X] Download and use the lastest stable version [X] See if the issue has already been reported [X] Debug

Side notes(Read then del this chunk)

https://gist.github.com/qualityplatforms/068c5bf75008cea736014d2e665293c6

mattparksjr commented 6 years ago

Having long conversations may be an issue. I cannot seem to replicate it. If someone else can replicate this, we will look into fixing it.

Cowprod commented 6 years ago

Hi,

Same problem here, all emails from a member of my team are empty. [_body:SSilence\ImapClient\Section:private] is always empty. I suspected his email client but I use Outlook for IOS like him without any problem. We both use an Office 365 account of the same organisation to send emails.

I can reproduce the case, so if I can help do not hesitate.

Regards,

b-and-p commented 5 years ago

I have the same issue I believe, I am trying to fetch exactly same email from Office 365 via POP3, that previously worked without problems via IMAP coming from outtlook.com server. Perhaps there is an issue with Office 365 message structure? It has 'html' but no 'plain'.

As a workaround I added this in IncomingMessage.php, line 409:

$objNew->text = null;

        //!debug
        $foo = $objNew->html->body;
        $objNew->text->body = strip_tags(imap_base64($foo));

Now, I am getting the body from 'html'

b-and-p commented 5 years ago

Ok, my problem is office365 related, not a bug, reference: https://communities.bmc.com/thread/167192?start=0&tstart=0

cbielich commented 5 years ago

When you implemented $objNew->text->body = strip_tags(imap_base64($foo)); Does the body still come in as HTML?

cbielich commented 5 years ago

I was having a similar issue using plain but works using text

$message = $mail->message->html; if (trim($message) == '') { $message = $mail->message->text; }