Jump to content

Get Unread Gmail Messages in PHP


smarcus3

Recommended Posts

I am trying to run this but it wont work. I get the following error. Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox in /home/u984345410/public_html/default.php

 

Here is a snipit of the code

 

function CountUnreadMails($login, $passwd) {
      $mbox = imap_open("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", $login, $passwd, OP_READONLY);
      $count = 0;
      if (!$mbox) {
           echo "Error";
      } else {
           $headers = imap_headers($mbox);
           foreach ($headers as $mail) {
                $flags = substr($mail, 0, 4);
                $isunr = (strpos($flags, "U") !== false);
                if ($isunr)
                $count++;
           }
      }

imap_close($mbox);
return $count;
}

Link to comment
Share on other sites

thanks but that didn't work.

 

Still gives this error

 

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX in /home/u984345410/public_html/default.php on line 41

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.