TomT Posted May 11, 2010 Share Posted May 11, 2010 I've amended the script below and it works as expected. What I would like to do is update it so I can move messages from INBOX to various IMAP folders based on specific criteria: ie: Subject contains **SPAM** move to 'Junk' TO contains Tom move to 'Inbox.Tom' FROM contains [email protected] move to Inbox.Ebay think you get the idea This my starting code: Code: <?php /* connect to imap */ $hostname = '{127.0.0.1:143}INBOX'; $username = 'user'; $password = 'pass'; /* try to connect */ $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to $hostname: ' . imap_last_error()); /* grab emails */ $emails = imap_search($inbox,'ALL'); /* if emails are returned, cycle through each... */ if($emails) { /* put the newest emails on top */ rsort($emails); /* for every email... */ foreach($emails as $email_number) { /* get information specific to this email */ $overview = imap_fetch_overview($inbox,$email_number,0); $msg_id=$overview[0]->msgno; $subj=$overview[0]->subject; imap_mail_move($inbox,$msg_id,'INBOX.New'); } } /* close the connection */ imap_close($inbox); ?> Any Ideas ? Thanks Link to comment https://forums.phpfreaks.com/topic/201338-filtering-email-using-imap/ Share on other sites More sharing options...
TomT Posted May 11, 2010 Author Share Posted May 11, 2010 Can anyone help me with this ? Thanks Link to comment https://forums.phpfreaks.com/topic/201338-filtering-email-using-imap/#findComment-1056443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.