fmbiete / Z-Push-contrib

Z-Push fork with changes that I will try to contrib
GNU Affero General Public License v3.0
134 stars 62 forks source link

iPhone receives HTML instead of MIME - Bad bodyPreference choice #211

Closed norm2k closed 9 years ago

norm2k commented 9 years ago

I am getting a lot of the following error in my debug log: Mail_mimeDecode()::_autoconvert_encoding(): Text cannot be correctly decoded, using original text. This will be ok if the part is not text, otherwise expect encoding errors This is causing most of my HTML emails to display at plain text on my iPhone. I am currently using the latest code with PHP 5.4.41-0+deb7u1. Anyone have any tips to get better results or know how to fix? This is new behavior for me. Thanks.

fmbiete commented 9 years ago

I think this is related to #202

PhilPhonic commented 9 years ago

same problem here with commit 471cefb874af3ce53468313c1e116b28c3ddbf52

fmbiete commented 9 years ago

@PhilPhonic , @norm2k Do you remember the last version that works in your iPhone?

ghost commented 9 years ago

Html email started working properly in my iphone again after checking out cc48500. I also tried to checkout dcc5960, but with that one, the problem appeared again. (i haven't tried any other than those)

fmbiete commented 9 years ago

Thanks!! that reduces the problem, a bit. But I'm not sure yet if the problem is withing mimeDecode or the SMIME changes in IMAP.

Can you check if putting the include/mimeDecode.php file from cc48500 in your dcc5960 works?

ghost commented 9 years ago

I just tried using include/mimeDecode.php from cc48500, but it didn't work unfortunately. The same error as before Tried some more, dee36d1 works, but not dcb3f85, so the problem seem to appear there.

PhilPhonic commented 9 years ago

The last version I used was 290b0e641fcee4b6536832a03a00eb1d3f296241 I'm quite sure this version worked. I can't exactly tell which version was the last one working, because I directly migrated to 471cefb874af3ce53468313c1e116b28c3ddbf52

fmbiete commented 9 years ago

Could you check again with the last version, please?

PhilPhonic commented 9 years ago

I just upgraded to the lastest version, but html mails are still displayed as plaintext on my iPhone.

fmbiete commented 9 years ago

Can you post this log lines (DEBUG level)?

BackendIMAP->GetMessage(): Message is multipart: %d, smime: %d, smime encrypted: %d
BackendIMAP->GetMessage - getBodyPreferenceBestMatch: %d
BackendIMAP->GetMessage - after thinking a bit we will use: %d
PhilPhonic commented 9 years ago

There you go:

12/07/2015 09:54:27 [13362] [DEBUG] [mail@example.com] BackendIMAP->GetMessage(): Message is multipart: 1, smime: 0, smime encrypted: 0 12/07/2015 09:54:27 [13362] [DEBUG] [mail@example.com] BackendIMAP->GetMessage - getBodyPreferenceBestMatch: 2 12/07/2015 09:54:27 [13362] [DEBUG] [mail@example.com] BackendIMAP->GetMessage - after thinking a bit we will use: 2

fmbiete commented 9 years ago

There is also a line like this one:

BackendIMAP->GetMessage('be1b3140', '114', '2')

The third parameter is a list of supported formats by the mobile.

For example, my Nexus 4 only tells it support HTML, a Sony Xperi tell 2 and 1...

fmbiete commented 9 years ago

@PhilPhonic can you tell me also if the backend/imap/config.php defined is false?

define('MAIL_PREFER_MIME_TYPE', true);

By default is false, but I think we should change it to true, otherwise iPhone would fail... And the last fixes in BackendIMAP should cover the Android device, that don't support MIME.

ghost commented 9 years ago

When setting that to true, html emails shows correctly, however, the small description under each email shown in the inbox is still html code.

PhilPhonic commented 9 years ago

The DEBUG Log sais it supports Plain text & HTML:

12/07/2015 09:54:27 [13362] [DEBUG] [mail@example.com] BackendIMAP->GetMessage('f78f31cf', '526', '1,2')

Now i set:

define('MAIL_PREFER_MIME_TYPE', true);

HTML is working now.

@danielpo what do you mean by "small description under each email"?

fmbiete commented 9 years ago

It means the preview showed in the message list windows.

The last commit should fix the problem and it also removes the MAIL_PREFER_MIME_TYPE option; BackendIMAP will choose by us.

fmbiete commented 9 years ago

Sorry, I have removed too much code. The previous commit reintroduced the problem, this one should fix it.

norm2k commented 9 years ago

I have been using this new code for over 5 days and all of my email (and preview) have been displayed correctly so far. Thanks for your hard work @fmbiete I really appreciate it!

fmbiete commented 9 years ago

Thanks for letting me know!! I close this, but if someone continues having problems feel free to reopen it.

mdave commented 9 years ago

Hi -- I'm using 3f9f12c and still seeing the preview appear in HTML, although the messages themselves are fine. I'm on iOS 8.4.

fmbiete commented 9 years ago

@mdave Can you paste some WBXML logs for a GetMessage?

norm2k commented 9 years ago

I had a similar problem. I am on IOS 8.1. I had to remove the email profile from the phone and add it agin. That solved the problem for me. You could also just use z-push-admin.php to do the same thing without having to reconfigure your email settings...

mdave commented 9 years ago

@fmbiete Okay, here is the entry from the log. I've extracted the bit that others above seem to have supplied:

20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->StatMessage('dc6f5409','27985')
20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->getImapIdFromFolderId('dc6f5409') = INBOX
20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->GetMessage('dc6f5409', '27985', '1')
20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->getImapIdFromFolderId('dc6f5409') = INBOX
20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->StatMessage('dc6f5409','27985')
20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->getImapIdFromFolderId('dc6f5409') = INBOX
20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->GetMessage(): Message is multipart: 1, smime: 0, smime encrypted: 0
20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->GetMessage(): getBodyPreferenceBestMatch: 1
20/07/2015 17:22:04 [19043] [DEBUG] [mail@example.com] BackendIMAP->GetMessage(): after thinking a bit we will use: 2

@norm2k I had assumed something similar might work. I have two devices on one account -- don't know if that should make a difference. In any case, just now I nuked both, ran the z-push-admin.php script to junk the state data too and tried again, but no dice for me.

mdave commented 9 years ago

After observing emails over the last 2 days, it seems that the summaries for everything that's been received after I posted my reply here seem to be fine. I guess there is a cache either on the phone/iPad or on my z-push installation that I didn't nuke properly. I'd suggest, since it seems to be working for others, that you could close this and I will update in case something breaks later on, but hopefully this is just a transient issue!

fmbiete commented 9 years ago

ok. Let me know if it happens again.