开发者

PHP Imap extension vs. Horde Framework imap client (or other alternatives)

For a web application I need to read mails from an imap server with php.

So far i have used a very simple script and the php imap extension, but because i need a robust solution (i also tried p开发者_开发百科ear imap packages, but it was not very reliable with different encodings), that supports more features like pgp encrypted emails, i have been thinking about using the horde framework/imap client instead.

I don't know if it's worth to install and use the (rather complex) horde framework just for the imap functions. Are there any alternatives or suggestions? what would be the advantages/disadvantages of using horde vs the php imap extension?

(The application is not supposed to provide any webinterface, i just need to parse mails and save contents/attachements to a database)

UPDATE I tried the Horde Imap Client, it's easy to install and use, but the performance seems a little bit slow compared to the php imap extension (on php5.3+eAccelerator). Login on imap server + fetch headers takes 8 seconds (login 4.5s + fetch headers 3.5s), compared to less than 4 seconds with php imap extension (login 3s + fetch headers 0.5s). I'm still trying to figure out wether i'm doing something wrong or this is just the normal difference between a native php library vs php imap extension.


You can install the Horde IMAP library without setting up the whole framework too:

$ pear channel-discover pear.horde.org
$ pear install horde/horde_imap_client


You could use the Zend_Mail component from Zend Framework. I dunno if its more/less complex than Horde, but you can grab just that component and its dependencies you dont need all of ZF.

Reading messages with Zend_Mail


The horde libraries do some basic housekeeping and queries when they log onto the mail server, the big one being "ENQUIRE INBOX", which can take a significant amount of time with a large folder.

The IMAP extension that comes with PHP does not do this. You can speed up these queries by installing and using Horde_Cache.

The IMAP extension that comes with PHP has many gotchas, for example it can struggle to log into exchange servers, gmail, etc. I have found from experience that it's worth learning and using the horde library to get around these problems, it should take you a couple of hours to produce something that works. When it comes to things like extracting mime attachments from an email body, i personally have found horde to be easier for this. your mileage may vary.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜