Currently I\'m using the PEAR library\'s mimeDecode.php for parsing incoming emails. It seems to have a lot of issues and fails to decode a lot of messages, so I\'d like to
I know this question's four years old now... but I ended up in need of a mail parsing library and wasn't satisfied with any of the available options. I wanted something reliable, PSR-2 compliant, installable via composer.
composer require zbateson/mail-mime-parser
It's its own parser, built from the ground up to get around known issues and bugs in other implementations. It is extensively tested and quite widely used.
The library makes use of Psr7 streams which allow you to pass it any kind of stream you like. It also doesn't store all information in memory -- very large attachments can be returned as a stream instead of a string if so desired, so memory isn't used up. Similarly the entire message is never stored directly in memory, only references to streams, and headers are kept in-memory.
https://github.com/zbateson/mail-mime-parser
Check out the website for a guide and the API... and if you find bugs/typos or see improvements, please feel free to open an issue, or dig right in and contribute with a pull request :)