Skip to content Skip to sidebar Skip to footer

PHP Get unread Emails count in Gmail Account

Reading Time: < 1 minute

How to get unread Emails count in Gmail Account using PHP.You can get unread Emails count by gmail feeds.Here is a example how to get unread email count in your gmail account. In here you must enter your gmail user name and password to access account.Another article, I was describes PHP Import Email Addresses from Gmail Accounts.But there user must be grant access his account to access data.I’ll describes how to access by using user grant access to get email count in later article.

You must only run this file to get unread email count.

How to call use above function.

//calling function
header('Content-Type:text/html; charset=UTF-8');
$feeds = check_email("[email protected]", "yourpassword");
$xmlobjc = new SimpleXMLElement($feeds);
echo $xmlobjc->fullcount[0];

If you want to get xml format, you must set the Content-Type as xml.

//making page to behave like xml document to show feeds
header('Content-Type:text/xml; charset=UTF-8');
echo $feed;

That’s all.