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...