首页 > PHP 在 imap server 中把邮件设置为 seen 问题

PHP 在 imap server 中把邮件设置为 seen 问题

如题,我希望读取 imap server (gmail) 中的未读邮件,获得其内容后再把邮件设置为已读,可是 imap_setflag_full 这个函数貌似不起作用。现在能够读取内容,但是无法把内容设置为seen, 代码如下

$mbox = imap_open("{imap.gmail.com/imap/ssl/novalidate-cert}INBOX", "XXX@gmail.com", "XXX");

try
{
    if($mbox){
        //trouver les numéros de mails non-lus
        $mails_unseen = imap_search($mbox, 'UNSEEN');
        //print_r($mailunseen);

        if (!empty($mails_unseen)){
            //pour chaque mail non-lu
            foreach($mails_unseen as $mail){
                //pour les mail unipart
                echo "hehe";
                imap_setflag_full($mbox, $mail, "\\Seen \\Flagged", ST_UID);   //mettre état de mail à déjà-lu

            }
        }else{
            throw new Exception("Pas de mail recent");
        }

        imap_close($mbox);

    }else{
        throw new Exception("Appel echoue");
    }
}

catch(Exception $e)
{
    echo 'Message: '.$e->getMessage().PHP_EOL; 
}

已经参考了 stakoverflow 上的一个回答 http://stackoverflow.com/questions/6765736/set-an-mail-as-seen-on-imap-server

可是还是不行...

【热门文章】
【热门文章】