Question

I am the admin of a Google domain and I need to he able to read users emails in my php app. How is this possible? I have tried to use IMAP but it won't even connect. Is there something special that apps have to do?

Was it helpful?

Solution

Here is a list of all the ways to read a user's Gmail mailbox, outside of App Engine :

  • IMAP, as you said. Provided it is enabled on your domain. Most of our customers disable it for security reasons (no audit trace of the connections).
  • Apps Script, but it requires the user's consent, even if you're an admin
  • The Email Audit API, but an Email extraction takes approximately 2 weeks (no kidding)

If IMAP is enabled on your domain, then it's the best choice. However, by default GAE does not allow outgoing connections apart from HTTP requests. The workaround for this limitation is the Sockets API, currently in preview. You can check it out here.

Note that you will also need to use an OAuth2 service account (domain-wide delegation) and IMAP-XOAuth2 to authenticate with the IMAP protocol.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top