Yuv
Yuv

Reputation: 202

Accessing Gmail emails through google app engine

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

Upvotes: 5

Views: 3950

Answers (3)

radzserg
radzserg

Reputation: 1396

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('[email protected]');
$client->setAccessType('offline');  
$client->setScopes([Google_Service_Gmail::GMAIL_READONLY]);

$service = new Google_Service_Gmail($client);
$messagesResponse = $service->users_messages->listUsersMessages('me');

Upvotes: 0

Amber
Amber

Reputation: 527538

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

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

Upvotes: 1

Cuong Thai
Cuong Thai

Reputation: 1165

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

Upvotes: 0

Related Questions