PHP sets email as seen in imapserver

Source: Internet
Author: User
Tags imap
For example, I want to read unread emails from imapserver (gmail) and set the email to read after obtaining the content. However, imap_setflag_full does not seem to work. The content can be read now, but cannot be set to seen. The Code is as follows {code ...} parameter... for example, I want to read unread emails from imap server (gmail) and set the email to read after obtaining the content. However, imap_setflag_full does not seem to work. The content can be read now, but cannot be set 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; }

An answer http://stackoverflow.com/questions/6765736/set-an-mail-as-seen-on-imap-server on stakoverflow has been referenced

But it still doesn't work...

Reply content:

For example, I want to read unread emails from imap server (gmail) and set the email to read after obtaining the content. However, imap_setflag_full does not seem to work. The content can be read now, but cannot be set 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; }

An answer http://stackoverflow.com/questions/6765736/set-an-mail-as-seen-on-imap-server on stakoverflow has been referenced

But it still doesn't work...

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.