-
Notifications
You must be signed in to change notification settings - Fork 459
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
Encoding Issues Driving Me Insane! #543
Comments
I think the issue with that approach is different chunks of the message can be encoded differently- you'd need to be able to inspect |
Thanks for the reply. So how do i do that then? What you're describing is some static properties, but i'm looping over IncomingMail objects and there is no $mailObj->charset there is also no property $mailObj->dataInfo ? This is after pulling a mail in like so:
So in my example $remoteEmail->charset and $remoteEmail->dataInfo both do not exist. |
I'm referring to class properties, not static properties- specifically: php-imap/src/PhpImap/IncomingMail.php Line 35 in 7ca3d19
php-imap/src/PhpImap/DataPartInfo.php Line 38 in 7ca3d19
|
Thanks, so $dataInfo is protected so how am i supposed to access that information? I don't see a public method that returns it. |
You proposal would need to be modified (at least in part) to either make these A property would need to be routed through magic getters, and a method's return type would need to be defined for single body + single charset, multiple body + single charset, and multiple body + multiple charset. The proposed technique would also likely need to account for non-inline text-based attachments. |
ok, i was hoping the library would literally just have the html body encoding set on it without all this messing around. |
I think I found the issue: decodeMimeStr() is called via convertEncodingAfterFetch(). However, at this point in time, the string no longer has the MIME header info. Hence, using imap_mime_header_decode() in decodeMimeStr() will not work and it then does not convert the encoding. php-imap/src/PhpImap/DataPartInfo.php Line 111 in 7ca3d19
php-imap/src/PhpImap/Mailbox.php Line 1347 in 7ca3d19
I fixed it like this: Mailbox.php
DataPartInfo.php
|
@hrst merge request, your fix is working for me |
@hrst Hi, your fix works well for me too. Is there any plan to merge it soon? |
I've created a merge request with those changes and merged it into the |
@Sebi94nbg When will there be a new release with this fix in it? |
I've just updated and the new version actually re-introduces the problem: php-imap/src/PhpImap/DataPartInfo.php Lines 111 to 114 in f401d85
decodeMimeStr() is called with a second parameter, but the method does not even have it? Also here: php-imap/src/PhpImap/Mailbox.php Line 1262 in fb8be23
I'm very confused on what the intention here was. Am I missing something and a second decodeMimeStr() method exists somewhere that does have the second parameter? I could not find it. See the method here: php-imap/src/PhpImap/Mailbox.php Line 1385 in f401d85
I suspect you'd want to use convertToUtf8() in both cases. I'll update my code accordingly. |
The |
The current version has the same issues again, please check this comment for a fix: |
Hi
I like this library but i am going insane with the encoding. Pulling 5000 emails from GMAIL works fine, but a lot of the html has encoding problems. I can't even seem to convert it all to proper UTF-8 with mbstring or utf8_encode, i just still have weird characters all over the place. I also can't just insert the html directly as the utf8 database wont' accept it.
There must be a way to have the emails displaying properly! Can someone help me here, ideally i should be able to just get the encoding from the message object, something like:
/** @var PhpImap\IncomingMail */
$mesaage->getEncoding()
But there doesn't seem to be such a thing on the IncomingMail object, if i could know what the encoding was then i could use mbstring to convert it properly.
The text was updated successfully, but these errors were encountered: