Writing an efficient cron job script utilizing Zend_Mail_Storage_Imap.

Posted by fireeyedboy on Stack Overflow See other posts from Stack Overflow or by fireeyedboy
Published on 2010-04-15T23:25:17Z Indexed on 2010/04/16 0:13 UTC
Read the original article Hit count: 640

Filed under:
|
|
|
|

I'm new to the IMAP protocol and Zend_Mail_Storage and I'm writing a small php script for a cron job that should regularly poll an IMAP account and check for new messages, and send an e-mail if new messages have arrived.

As you can imagine, I want to only poll the IMAP account for relevant messages, and I only want to send a new e-mail if new messages have arrived since the last polled new message. So I thought of keeping track of the last message I polled with some unique identifier for a message.

But I'm a bit uncertain about whether the methods I want to utilize for this do what I expect them to do though.

So my questions are:

  • Does the iterator position of Zend_Mail_Storage_Imap actually resemble some IMAP unique identifier for messages, or is it simply only and internal position of Zend_Mail_Storage_Abstract? For instance, if I tell it to seek() to message 5 (which I stored from an earlier session) will it indeed seek to the appropriate message on the IMAP server, even if for instance messages have been deleted since last session?
  • Would keeping track of this latest polled message id in a file suffice for a cron job that, say, polls the account every 5 or 10 minutes? Or is this too naive, and should I be using a database for instance.
  • Or is there maybe a much easier way to keep track of such state with Zend_Mail_Storage_Abstract?
  • Also, do I need to poll every IMAP folder? Or is everything accumulated when I poll INBOX?

If you could shed some light on any of these matters, I'ld appreciate it. Thanks in advance.

© Stack Overflow or respective owner

Related posts about zend-mail

Related posts about imap