Bad Message Number in IMAP

I am a php beginner and I am working on a mail parser. For that, I am going through PHP’s IMAP functions which I wrote inside a mailParser class.

function __construct(){
    $this->stream = imap_open($this->server,$this->username,$this->password) or 
    die('Cannot connect to Gmail'.imap_last_error());

When I ran this:

function getInboxHeaders(){
    $tot_msg = imap_num_msg($this->stream);

        $header = imap_header($this->stream,$count);

inorder to get the headers of the messages on my Inbox, I was notified of the warning “Bad message number”. Why do I get such a warning upon running this function?

I am really hoping that somebody could know the reason behind this.

Sponsor our Newsletter | Privacy Policy | Terms of Service