Skip to content
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

Iconv Exception #78

Closed
darit opened this issue Mar 19, 2015 · 8 comments
Closed

Iconv Exception #78

darit opened this issue Mar 19, 2015 · 8 comments
Labels
Milestone

Comments

@darit
Copy link
Contributor

darit commented Mar 19, 2015

Hello,
I get the attachments from the mailbox's unread messages using $attachment->getDecodedContent() and I'm having some trouble with them. They are UTF-8 XML. The transcode method is causing an Exception on iconv function saying it has an illegal character.
https://github.com/ddeboer/imap/blob/master/src/Message/Part.php#L185-L188
I just changed this to:
https://github.com/darit/imap/blob/master/src/Message/Part.php#L185-L189
This change works fine for me.
darit@3ba77f1?diff=unified

@danilor
Copy link

danilor commented May 4, 2015

I am having the same problem, specially from a couple of emails comming from ebay.

So I am implementing your solution and I hope in the future the library gets the fix.

@danilor
Copy link

danilor commented May 4, 2015

Sadly didnt work for me.

I will have to check for another solution.

Thanks anyway.

@npub
Copy link

npub commented Jun 13, 2015

Same problem.

In my case: a broken email's title prevents fetching the message: body, attachments and etc.
Call $message->getID(); throws at …/ddeboer/transcoder/src/IconvTranscoder.php:32:

[Ddeboer\Transcoder\Exception\IllegalCharacterException]
String "?ӧ֧ܧ? 2015/16 ?C ???֧ԧ?" contains an illegal character: iconv(): Detected an illegal character in input string

Is it any way to ignore IllegalCharacterException to take access to others not broken parts of email?

@Lewiscowles1986
Copy link

I Have a separate problem that may be related in some way

PHP Notice:  Undefined property: stdClass::$mailbox in ~/projects/php/email-harvest/vendor/ddeboer/imap/src/Message/Headers.php on line 78
PHP Stack trace:
PHP   1. {main}() /home/lewis/projects/php/email-harvest/harvest.php:0
PHP   2. Ddeboer\Imap\Message->getId() ~/projects/php/email-harvest/harvest.php:30
PHP   3. Ddeboer\Imap\Message->getHeaders() ~/projects/php/email-harvest/vendor/ddeboer/imap/src/Message.php:46
PHP   4. Ddeboer\Imap\Message\Headers->__construct() ~/projects/php/email-harvest/vendor/ddeboer/imap/src/Message.php:185
PHP   5. Ddeboer\Imap\Message\Headers->parseHeader() ~/projects/php/email-harvest/vendor/ddeboer/imap/src/Message/Headers.php:23
PHP   6. Ddeboer\Imap\Message\Headers->decodeEmailAddress() ~/projects/php/email-harvest/vendor/ddeboer/imap/src/Message/Headers.php:64
Encoding from `x-unknown' to `UTF-8' is unsupported on this platform: iconv(): Wrong charset, conversion from `x-unknown' to `UTF-8' is not allowed

@danilor
Copy link

danilor commented Sep 26, 2016

Kind of late. one year without an answer. I guess this forum will never get an answer :)

@Lewiscowles1986
Copy link

Lewiscowles1986 commented Sep 26, 2016

Well I'm not sure it will if we all take that attitude... Combing the PR's it seems modifying the transcoding library to include some try catch statements helped to silence and decode a lot of messages that were x-unknown, some variant of ascii or utf-8. It's not solved, but certainly progress. Btw, most decoded into readable English, not all did

@Slamdunk Slamdunk added the bug label Sep 22, 2017
Slamdunk added a commit that referenced this issue Sep 27, 2017
Message charset: mb_convert_encoding + aliases
Closes #78 #85 #115 #132 #136 #158 #165 #171 #174 #176
@Slamdunk Slamdunk added this to the 1.0 milestone Sep 27, 2017
@Slamdunk
Copy link
Collaborator

Thank you for the feedbacks. The issue should be resolved by #196

@skrepecki
Copy link

class IconvTranscoder implements TranscoderInterface{
.....
public function transcode($string, $from = null, $to = null){
.....
if($from == 'auto') $from = 'UTF-8';
}
}

php 7.4
this works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants