954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to move email to new folder using zend_mail and zend_mail_storage_imap

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.

rcavezza
Newbie Poster
3 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

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.

mschroeder
Work Harder
Team Colleague
666 posts since Jul 2008
Reputation Points: 279
Solved Threads: 131
 

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?

rcavezza
Newbie Poster
3 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: