Read all mails from gmail api using oauth

冷暖自知 提交于 2019-11-29 19:41:21

问题


Is there any method to read all mails ie:read and unread both from gmail Api using oauth the following link returns only new mails

 https://gmail.google.com/gmail/feed/atom

So i want all Emails to be retrieved Please help me


回答1:


On June 25, 2014 Google released new Gmail API that can be used to easily gather messages, threads, labels and more from Gmail accounts. Service is OAuth 2 protected. They provide nice client libraries for Python, .NET and Java and wonderful documentation for those doing RESTful implementation.

I suggest using their API instead of IMAP - because Gmail has and supports many features that were not designed to run over IMAP. Features like search, tagging, etc...

You can also check their YouTube video for a nicer introduction.




回答2:


edited: IMAP example to retrieve email count. Shows the count of all my mails. Seems to work this way.

<?php

$imap = imap_open('{imap.gmail.com:993/imap/ssl}INBOX', $username, $password);
$emails = imap_search($imap, 'ALL');

if($emails) {
        echo count($emails);
}

imap_close($inbox);
?>



回答3:


There is sample code. Alter the code as per your needs.. https://developers.google.com/google-apps/gmail/xoauth2_libraries



来源:https://stackoverflow.com/questions/8179103/read-all-mails-from-gmail-api-using-oauth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!