开发者

Processing IMAP email in PHP

I need to process an email inbox, monitor it for messages with a particular subject line. If it finds a match I need to get the body content, manipulate, and insert into a database. Ideally would mark the message as read and mov开发者_Python百科e it to another IMAP folder as well.

I'm poking around PHP documentation imap_open (http://us2.php.net/imap_open) and found a link http://www.linuxscope.net/articles/mailAttachmentsPHP.html#_jmp0_

Before I get too far, I'm wondering if anyone is aware of an existing PHP class that's a good wrapper for the basics I'm looking for:

IMAP:

  • connect
  • list folders
  • list messages
  • read messages - from, to, subject, body
  • move messages to server folders
  • read/unread status

Thank you!


I've not used it for anything but sending mail, but it appears that the Zend_Mail component will get you at least most of the way there. It doesn't seem to support moving messages on the server, but you could probably extend it fairly simply.


I've tried Zend_Mail for IMAP and have some highs and lows. I could connect and read, move emails but it is quite buggy. You can check for subject or sender, parse headers, reach attachment by parsing different parts.

Zend_Mail_Protocol_Imap is not using any of the PHP imap/ext function. (Why?) Reading folders with thousands of emails is slow. The internal order of a folder is not actually chronological, which is so strange. Probably depends on how the storage was implemented (I parsed a google.pro account). Sometimes the connection closes unexpectedly and debugging it is quite heavy.

There is also a Pear_IMAPv2, which is beta and I could not even succeed in installing. The alternative will be to install imap/ext and do everything by yourself.

Good luck.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜