php-imap extension == evil
- Last Updated on Saturday, 04 June 2011 12:56
- Published on Thursday, 04 June 2009 18:14
- Written by David L Norris
The PHP IMAP extension relies on University of Washington's libc-client IMAP library which appears to be written by novice students (in 1988!). After some review of the source code, UW's IMAP client library appears to have extensive, serious security and stability problems at very fundamental levels.
I'm seeing segfaults (buffer overflows) performing simple operations like fetching attachments. Some attachments work fine but others fail; larger files especially. There are bug reports and CVE entries related to similar issues. However, upgrading to the supposed "fixed" versions of everything does not make any difference for my specific issue. It does fix some other issues related to this. (i.e. the exact same programming errors that appear to affect thousands of lines of code in the UW client.)
Use one of the many native IMAP class library. My choice would be Zend_Mail as we use Zend Framework extensively here at work. Zend_Mail supports a number of other mail protocols in addition to IMAP. MIME type support is likely much better than other options. The other logical choice would be Pear Net_IMAP.