Accessing Gmail emails through google app engine

2019-06-21 19:16发布

How to get the e-mail contents by getting the user's login details in google app engine?

3条回答
爷、活的狠高调
2楼-- · 2019-06-21 19:20

You can also use google service account. https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount Then you can use it in order to get access to account under your domain.

$client = new Google_Client();
$client->setApplicationName('My App');
$client->setAuthConfigFile('path/to/service_account.json');

$client->useApplicationDefaultCredentials();
// account that we want to check 
$client->setSubject('account@mydomain.com');
$client->setAccessType('offline');  
$client->setScopes([Google_Service_Gmail::GMAIL_READONLY]);

$service = new Google_Service_Gmail($client);
$messagesResponse = $service->users_messages->listUsersMessages('me');
查看更多
【Aperson】
3楼-- · 2019-06-21 19:27

Try taking a look at the GMail API. You'll probably want to use OAuth.

https://developers.google.com/gmail/

查看更多
Bombasti
4楼-- · 2019-06-21 19:33

This is exactly what I'm doing in my current project. Google App Engine Blog introduced a company named "Context.IO" and they provide very easy API to access GMail. I've implemented it in my project successfully.

Links
GAE Blog
Demo (You can look for a contact, and get all its emails...)

My Experience
They also provide a Explore feature that allow you to post and get json data from your gmail accounts.
However, if you registered for a free API key here, they will limit to 3 mailboxes per day. You can run a cron job to delete it daily. The nice thing is that you can contact them to get more mailboxes for development purposes :)

Hope my experience can help you

查看更多
登录 后发表回答