0

Using PHP's IMAP functions, I want to move 10 messages from the folder "xyz_msg" to the folder "xyz_tmp"

Below is the code I use to connect to the email server.

<?php 
 
$mbox = imap_open ("{imap.gmail.com:993/imap/ssl/novalidate-cert}xyz_tmp", "example@gmail.com", "password") 
     or die("can't connect: " . imap_last_error());  
 
$imap_obj = imap_check($mbox); 
echo "<pre>"; 
var_dump($imap_obj); 
echo "</pre>"; 
 
$check = imap_mailboxmsginfo($mbox); 
 
if ($check) { 
    echo "Date: "     . $check->Date    . "<br />\n" ; 
    echo "Driver: "   . $check->Driver  . "<br />\n" ; 
    echo "Mailbox: "  . $check->Mailbox . "<br />\n" ; 
    echo "Messages: " . $check->Nmsgs   . "<br />\n" ; 
    echo "Recent: "   . $check->Recent  . "<br />\n" ; 
    echo "Unread: "   . $check->Unread  . "<br />\n" ; 
    echo "Deleted: "  . $check->Deleted . "<br />\n" ; 
    echo "Size: "     . $check->Size    . "<br />\n" ; 
} else { 
    echo "imap_check() failed: " . imap_last_error() . "<br />\n"; 
} 
 
imap_close($mbox); 
 
?>
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by cwarn23
0

Could you provide a better description of your code (perhaps php comments) and describe in more detail why you can't do it. The theory behind it is you search through to inbox in a loop then as you retrieve them the messages go through an if statement and if that if statement passes then it will transfer that message across one by one in the loop.

0

Thank you cwarn23 for your reply.

My code will connect to the server but it doesn't move anything. I don't know what function to use that will move 10 messages from one folder to another folder.

Could you provide a better description of your code (perhaps php comments) and describe in more detail why you can't do it. The theory behind it is you search through to inbox in a loop then as you retrieve them the messages go through an if statement and if that if statement passes then it will transfer that message across one by one in the loop.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.