0

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(){
    imap_headers($this->stream);
    $tot_msg = imap_num_msg($this->stream);

    for($count=$tot_msg;$count>-1;$count--){
        $header = imap_header($this->stream,$count);
        print_r($header);
    }
 }

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?

charmjo
  • 13
  • 2
  • 6
  • What is $stream ? You need to pass $stream to the function, right? function getInboxHeaders( $stream ){ }. If you have $stream defined somewhere above the getInboxHeaders function, simply pass it to getInboxHeaders. But you must modify getInboxHeaders to accept a parameter : getInboxHeaders( $stream ) – Chris Medina May 18 '20 at 18:09
  • I apologize for the confusion. ``` $stream``` was supposed to be ```$this->stream ```. I also edited my question for the matter. – charmjo May 19 '20 at 06:03

0 Answers0