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

Mail with image couldn't be parsed successfully #95

Closed
markusramsak opened this issue Nov 14, 2019 · 6 comments
Closed

Mail with image couldn't be parsed successfully #95

markusramsak opened this issue Nov 14, 2019 · 6 comments

Comments

@markusramsak
Copy link

markusramsak commented Nov 14, 2019

The parsing of the attached .eml file (zip compressed so I could upload it) failed ... it seems to have something to do with the "Content-Type: image/png; charset=binary; name="logo.png"

Test.eml.zip

My source code for parsing the .eml file

$rawMessage = file_get_contents($pathToFile . 'Test.eml');
$mailParser = new MailMimeParser();
$message = $mailParser->parse($rawMessage);
$attachments = $message->getAllAttachmentParts();
foreach ($attachments AS $attachment) {
    /**             
      * @var \ZBateson\MailMimeParser\Message\Part\MimePart $attachment
      */
    $content = $attachment->getContent(); // error occurs
    // a lot more unimportant lines of code for what to do with the parsed attachment ...
}
@zbateson
Copy link
Owner

Hi @markusramsak

I was considering the existence of a "charset" attribute on a content-type header to be indicative that the content is not binary. I've added to that condition so a charset of "binary" is considered binary, but my guess is there may be other instances of this in the wild with other weird choices for charset.

Anyway, I'll release that for you. Thanks for reporting :)

@zbateson
Copy link
Owner

Released in 1.1.7

@markusramsak
Copy link
Author

Thank you for your quick reply, but I still get the same error ... :(
iconv_strlen(): Unknown error (22) [ROOT/vendor/zbateson/mb-wrapper/src/MbWrapper.php, line 397]

@zbateson
Copy link
Owner

Hi @markusramsak

Thanks for letting me know -- I've pushed a commit that should resolve this now, sorry about the back-and-forth there was a second part I missed.

I'll wait for you to confirm it first before releasing if you can.

Thanks

@markusramsak
Copy link
Author

With this change, it seems to work. Would you so kind as to release a new version, so I can use this improved version of your excellent parser. Thanks!!

@zbateson
Copy link
Owner

Excellent, re-released in 1.1.8. I'll close again, but feel free to comment/reopen if still an issue!

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

No branches or pull requests

2 participants