PHP set mail to seen problem in IMAP server

Source: Internet
Author: User
Tags imap
Title, I want to read unread messages in IMAP server (Gmail), get their content and then set the message to read, but the Imap_setflag_full function doesn't seem to work. Can now read the content, but cannot set the content to seen, the code is as follows

$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; }

Has consulted an answer on the Stakoverflow http://stackoverflow.com/questions/6765736/set-an-mail-as-seen-on-imap-server

But it's still not working.

Reply content:

Title, I want to read unread messages in IMAP server (Gmail), get their content and then set the message to read, but the Imap_setflag_full function doesn't seem to work. Can now read the content, but cannot set the content to seen, the code is as follows

$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; }

Has consulted an answer on the Stakoverflow http://stackoverflow.com/questions/6765736/set-an-mail-as-seen-on-imap-server

But it's still not working.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.