sending email programmatically using default user account

10,771

To send in the background, see the first link at your right on the list of related questions:

You need to use an email API such as JavaMail:

Sending Email in Android using JavaMail API without using the default/built-in app

Update based on the comments:

There is no way to send an email silently, without either:

  • letting the user know and accept it first (by using intents and an email provider)
  • or asking for the username and password before and using an email API as above (the user will implicitly give you the approval to send/receive emails by entering those values)

And that is a very good thing! There are too many security concerns otherwise. If you ever find a way, please post it as a bug report in android.

Share:
10,771
Prabhu M
Author by

Prabhu M

I am an Android Developer from Bangalore, India.

Updated on August 21, 2022

Comments

  • Prabhu M
    Prabhu M over 1 year

    I want to be able to send an email out of my app, based on the user pressing a button on my app's Activity. The email needs to be sent automatically by the application upon button press, i.e. I don't want to show another email form to the user. And the email should be sent using the user's default email account on the phone not an email account that I hardcode into my app. And I don't want to have the user key in their email credentials into my app's configuration, I just want to be able to call some android api and say "send this email with this subject and body to this email address, using the default account that the user has set up on the phone".

    Is this possible? If so, how?

  • Prabhu M
    Prabhu M almost 13 years
    Hi, it needs to set userid and password of sender . I want to send email using default user account of android phone
  • Aleadam
    Aleadam almost 13 years
    So you want to send an email silently, without letting the user know, and using the users passwords without asking for them? Well, I think that's borderline criminal.
  • Prabhu M
    Prabhu M almost 13 years
    I am developing a security application. so I dont want to let the thief knowing email is sending.. so I want send email in background..
  • Aleadam
    Aleadam almost 13 years
    @prabhu then ask for the user/pass combo once upon first run, store them, and use them later with the javamail api. You would expect that no thief will install the app, so what's the problem with that approach?
  • sandeepmaaram
    sandeepmaaram about 10 years
    @Aleadam if user already registered with his account, why we cannot send an email from his account without Intent.ACTION_SEND. if we use Intent.ACTION_SEND, only probem is, it is not giving any result code in onActivityResult() method. If we use JAVA Mail API, then user again enter username and password. Is there any alternative solution? thanx in advance....