I'm using these libraries for an email application I'm building.

$storage = new Zend_Mail_Storage_Imap($imap);

if (strpos($storage->getMessage($i),'chocolate') !== FALSE ) 

{
        //Move to chocolate folder here
}

Also, is there a way to put incoming emails from this sender to automatically go into the chocolate folder from now on? ...similar to how you can build labels in gmail and all mail from that sender will automatically go into that folder in the future.

You want to use the $storage->moveMessage( id, folder) method.
This site illustrates it a little more in detail: http://www.devcha.com/2010/06/how-to-removemove-messages-using-zend.html

The comments at the bottom of the Zend_Mail documentation also elaborate on this: http://framework.zend.com/manual/en/zend.mail.read.html

Automatically routing an email from a user to a particular folder would require some kind of intermediate logic that would look at all the emails and move them according to some kind of rule. Using a database or some kind of storage would make this possible.

Thanks for the advice and the links. I'm actually using google oauth for use with this application and I've seen gmail filters (although not with my existing application ) for folders. Is there a way to tap into Google's logic since all our users will be using their platform to access their mail?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.