Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use authToken to send email?

Somehow I managed to get AuthToken from Google in Android. Now I can't find how could I use this token to send email using the email id and the authToken without user interaction.

Please provide some example.

like image 768
asfiya Avatar asked Nov 05 '22 07:11

asfiya


1 Answers

You cannot send emails using Gmail programmatically unless you use SMTP or IMAP which in their standard form use password authentication.

However, there is an experimental GMail API that's based on OAuth (XAOUTH SASL) which you can use with SMTP AUTH command to authenticate to Gmail servers using standard 3 legged OAuth. With this, you should get a short lived token that you can use for sending emails. I haven't tried this on Android but I don't see why it shouldn't work:

http://code.google.com/apis/gmail/oauth/protocol.html

So, you can download the client libraries for this GMail API alongwith Java Mail and give it a try! There is a sample bundled which you can use for a quick proof of concept.

like image 152
Anirudh Avatar answered Nov 09 '22 09:11

Anirudh