mail fetching and MIME e-mail handling
Posted 24 September 2009 - 04:07 PM
My first thought was to leverage an existing webmail client, but it turns out they are all licensed under GPL, and hence would not allow us to do the tight integration required for this proprietary software project.
I looked around for e-mail client libraries, but found nothing really complete or up to date.
So we started down the hard path of developing from scratch, using the IMAP extension for PHP, which turns out to be pretty handy, though not very well documented. And despite it's name, it does not only IMAP, but also POP3, and supports SSL. Very nice.
About 10 hours into the actual work, I had a pair of classes that would connect to a POP3 or IMAP server, and let me list and iterate through the messages on the server. At which point, one of our Ruby/Rails developers came in and told us, hey, I can do that in a couple of hours - I was a bit baffled, but sure enough, with about three hours of work, he had not only e-mail fetching, but also a MIME parser up and a running.
With Rails, you simply write a handler for incoming e-mail, and it can decode MIME attachments for you and everything, so all you have to do is decide what you want to do with the content and implement that. Super easy.
I would have liked to stay in PHP for this project, but it appears that none of the PHP frameworks offer anything similar to this. Looking at various open-source webmail clients, they all seem to implement their own (extremely complex) MIME handling systems to cover all of the differences in e-mail from various exotic clients and servers.
This is kind of frustrating.
How come Ruby and Rails people get this functionality right out of the box, and the rest of us have to work like dogs to support mail fetching and MIME handling?
I would love to see Yii offering generic e-mail features. This sort of stuff should not need to be this complicated - it's the kind of stuff you'd like to see implemented once, and done right, rather than trying to reinvent the wheel for every project.
I never got as far as to decode MIME attachments - the IMAP extension takes care of fetching attachments, but doesn't seem to help with attachment decoding. From looking at various webmail client codebases, is extremely complicated, often some 5-10k lines of code, to handle every kind of message properly, including all the proprietary crap that comes out of Microsoft and Apple products.
I would be happy to do some cleanup and documentation of my e-mail fetching classes, if there's any interest.
But I'm afraid that's baby steps towards a framework with a full MIME message handling stack.
Love to hear any of your thoughts or ideas on this topic, as well as pointers if I missed some library out there?
Posted 19 September 2011 - 03:03 AM
It is nice to see that I am not the only one who crashes front-to-front with this problem. Right now I am dealing with the same situation that you already had, developing a email client and adding some other functions to integrate with other existing applications for a non-profit organization.
I didn't find anything really useful nor understandable/easily maintainable open source email client with MIME capabilities for an IMAP server.
Did you finally build / found something nice to manage IMAP mail?
Posted 17 April 2012 - 12:46 AM
Zend_Mail also have very limited options, you are even not able to use search options(in specifications there is notice that search function is only for internal use, so like this feature is not completed).
Last option is Horde_Imap, which is very complex library, without any tutorial how to use it.