How to get the number of unread Gmail emails

Can someone help me with the code to get the numbers of unread gmail letters in php?

0
source share
2 answers

Connect to gmail via IMAP using functions from the IMAP module http://php.net/manual/en/book.imap.php

$mbox = imap_open("{imap.example.org:143}INBOX", "username", "password") or die("can't connect: " . imap_last_error()); $MC = imap_check($mbox); // Fetch an overview for all messages in INBOX $result = imap_fetch_overview($mbox,"1:{$MC->Nmsgs}",0); $seen = 0; $unseen = 0; foreach ($result as $overview) { if($overview->seen){ $counter++; } else { $unseen++; } } imap_close($mbox); echo "Seen $seen, unseen $unseen" 
0
source

You can use some of this API to get your inbox: http://code.google.com/apis/gmail/docs/inbox_feed.html

But there are many libraries to access these feeds in PHp, I think.

0
source

Source: https://habr.com/ru/post/1385730/


All Articles