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 interaction. If I can avoid showing any UI, that would be the best solution. The one thing that is unacceptable is to either hardcode or request the user enter their e-mail credentials. The user had to have already setup their account such as Gmail with their credentials. All my app does is use an existing e-mail provider that has been setup.
Most of the posts I have found here use an Intent but from what I understand, that will show the e-mail UI and requires the user to press the Send button.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With