Как переместить почтовое сообщение в папку с php imap

Кажется, я не могу переместить свои почтовые сообщения в свою сохраненную папку. Вот мой код:

$mbox = imap_open("{".$mail_server.":".$mail_port."}".$mail_folder, $mail_username, $mail_password) or die("Error opening mailbox: ".imap_last_error()); $countnum = imap_num_msg($mbox); $msglist = array(); if( $countnum > 0 ) { $num = 1; while ($num <= $countnum) { $msglist[] = $num; $num++; }//end while loop } //move the email to our saved folder imap_mail_move($mbox,implode(',',$msglist),'INBOX/Saved'); imap_expunge($mbox); imap_close($mbox); 

Когда я запускаю этот скрипт, ничего не происходит. Сообщение остается в папке «Входящие». Есть предположения? Благодаря!

Solutions Collecting From Web of "Как переместить почтовое сообщение в папку с php imap"

От взгляда на документы для imap-mail-move () я вижу, что вы склеивали свой диапазон вместе с вашим счетчиком с 1, поэтому нет необходимости в цикле for:

 <?php $mbox = imap_open("{".$mail_server.":".$mail_port."}INBOX", $mail_username, $mail_password) or die("Error opening mailbox: ".imap_last_error()); $countnum = imap_num_msg($mbox); if($countnum > 0) { //move the email to our saved folder $imapresult=imap_mail_move($mbox,'1:'.$countnum,'INBOX/Saved'); if($imapresult==false){die(imap_last_error());} imap_close($mbox,CL_EXPUNGE); } ?>