2011-08-02 56 views
2

私のメールを保存したフォルダに移動できないようです。私のコードは次のとおりです: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); 

このスクリプトを実行すると何も起こりません。メッセージは受信トレイに残ります。何かご意見は?ありがとう!

答えて

5

1からアップ私はあなたが,と一緒にあなたの範囲を糊付けしまし参照imap-mail-move()のためのドキュメントを見て、あなたのカウントから、そのループのための必要性をtheresの:

<?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); 
} 
?> 
動作しませんでした
+0

いずれか – Rupert

+0

'が動作するにはいくつかのエラーが必要です –

+0

無効なメールボックス名が書かれていますが、どうすればいいのか分かりません。リスメールだけです。私はちょうどいいです。 'Saved'というフォルダを作成しました – Rupert

関連する問題