The imap_check ($stream); function will return real-time information about the e-mail box (at least imap) during one connection :)
(PHP 4, PHP 5, PHP 7)
imap_check — Check current mailbox
$imap
   ) : stdClass|falseChecks information about the current mailbox.
Returns the information in an object with following properties:
Date - current system time formatted according to » RFC2822
     
    Driver - protocol used to access this mailbox:
      POP3, IMAP, NNTP
     
    Mailbox - the mailbox name
     
    Nmsgs - number of messages in the mailbox
     
    Recent - number of recent messages in the mailbox
     
    
   Returns false on failure.
  
Example #1 imap_check() example
<?php
$imap_obj = imap_check($imap_stream);
var_dump($imap_obj);
?>
Exemplul de mai sus va afișa ceva similar cu:
object(stdClass)(5) {
  ["Date"]=>
  string(37) "Wed, 10 Dec 2003 17:56:54 +0100 (CET)"
  ["Driver"]=>
  string(4) "imap"
  ["Mailbox"]=>
  string(54)
  "{www.example.com:143/imap/user="foo@example.com"}INBOX"
  ["Nmsgs"]=>
  int(1)
  ["Recent"]=>
  int(0)
}
 add a note
 add a note
  
The imap_check ($stream); function will return real-time information about the e-mail box (at least imap) during one connection :)
You can prevent imap_check from flagging new/recent messages as checked by calling imap_open with the "/readonly" or OP_READONLY flags.
You can NOT prevent imap_check from flagging new/recent messages when using POP3 enabling the "/readonly" or OP_READONLY flags or options.
Running this on a mailbox will mark recent/new messages as checked.
