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.