I use the following code to count the number of unread messages in Gmail. However, it returns an error:
can't connect: Too many login failures
Is there anything I don't see here?
(IMAP and POP are included in the Gmail account I'm testing.)
NOTE. It seems to work (at least for most queries). However, it takes too long - maybe 2 - 3 minutes to return with the number. Is there any way to speed it up?
Thanks!
<?php $mbox = imap_open ("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", "username", "password", OP_READONLY) or die("can't connect: " . imap_last_error()); $check = imap_mailboxmsginfo($mbox); if ($check) { print $check->Unread; //. "/" . $check->Nmsgs; } else { print "Failed"; } ?>
source share