如何使用 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);
当我运行此脚本时,没有任何反应。该消息保留在收件箱中。有什么想法吗?谢谢!
I can't seem to move my mail messages to my saved folder. Here is my code:
$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);
When I run this script nothing happens. The message stays in the inbox. Any thoughts? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 imap-mail-move() 的文档我看到您已将范围与
,
粘合在一起,并且从 1 开始计数,因此不需要 for 循环:From looking at the docs for imap-mail-move() I see you've glued your range together with
,
and your counting up from 1 so theres no need for the for loop: