阻止imap_expunge删除未读消息

时间:2018-06-25 18:53:40

标签: php imap

我编写了一个脚本来获取主题中特定部分的所有已读消息。当我将它们设置为删除然后清除时,它还会删除主题中带有该部分的未读消息。我该如何预防?

    $check = imap_mailboxmsginfo($connection);
echo "Messages before delete: " . $check->Nmsgs . "<br />\n";


$count = imap_num_msg( $connection );
for ( $msgno = 1; $msgno <= $count; $msgno ++ ) {

    $headers = imap_headerinfo( $connection, $msgno );
    if ( $headers->Unseen == " " && strpos( $headers->subject, 'Urgente' ) !== false) {

        echo $msgno;
        $imapresult = imap_mail_move( $connection, $msgno, 'INBOX/old' );
        $del = imap_delete( $connection, "$msgno");
        $check = imap_mailboxmsginfo($connection);
        echo "Messages after  delete: " . $check->Nmsgs . "<br />\n";
    }

}

imap_expunge($connection);
$check = imap_mailboxmsginfo($connection);
echo "Messages after expunge: " . $check->Nmsgs . "<br />\n";

imap_close($connection);

0 个答案:

没有答案
相关问题