Send e-mail in Android without user interacton

前端 未结 2 658
感情败类
感情败类 2021-01-31 23:02

I would like to send an e-mail in my app using whatever default mail provider the user already has setup. It must be possible to send the e-mail without requiring any user inter

2条回答
  •  暖寄归人
    2021-02-01 00:00

    After some more digging around, I think there is a solution. Google has now added support for Gmail authentication using OAuth 2.0 which avoids the need to access the user's username and password. Since my app will require the user to have a Gmail account, this might be the solution. Of course this won't work for any other e-mail provider that doesn't support OAuth but since Google is concerned about protecting username/passwords, this approach seems to be right. Need to look into how to use OAuth from within my app, but theoretically it should be possible. Once a user grants permission to a Google service, the app receives a token that is used for the lifetime that the permission remains. The question that is still unresolved is whether Gmail supports sending an e-mail using OAuth:

    Google Brings OAuth 2.0 Support To Gmail And Google Talk To Make Third-Party Apps More Secure

    OAuth2 Support for Gmail

    Google's sample code for Gmail support and OAuth2

    Android app demonstrating how to send e-mail using OAuth

    YouTube video showing how a mobile app uses 2 step verification in an app

    Android docs on using OAuth 2.0

    Code sample to send e-mail using OAuth2

提交回复
热议问题