2

Is there anyway to get an email sent without putting the password into the code ?

There are many email api-s that enables to send an email with entering the username and password.

Example

sendEmail("myemail@gmail.com","mypass","subject","msg body"); 

Is there any way around the problem with hard-coding the password in code ?

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
Lukap
  • 31,523
  • 64
  • 157
  • 244
  • possible duplicate of [Sending email without hard-coding username and password](http://stackoverflow.com/questions/7270318/sending-email-without-hard-coding-username-and-password) – Jeff Foster Dec 23 '11 at 10:21
  • use encrypt-and-decrypt http://stackoverflow.com/questions/8397213/encrypt-and-decrypt-data-for-android-app-client/8397465#8397465 – Padma Kumar Dec 23 '11 at 10:24

2 Answers2

2

You have three options to send email:

  1. You include your email and password into the code and in this case the application will send emails from this email address.
  2. You can ask user to enter his credentials for his email and in this case you'll receive a mail from user's address.
  3. You can form an intent in your application that will fill neccessary fields and call user's email client to send this.

If you want silent way to send email then you should choose 1 or 2. But more secure way is to use the third approach.

Yury
  • 20,618
  • 7
  • 58
  • 86
  • are you sure that there is no other way to do this >? – Lukap Dec 23 '11 at 10:26
  • I want to clarify: are you asking about the possibilities how to send a email or about the ways how to store credentials not in the code but in other places? – Yury Dec 23 '11 at 10:49
  • I need any workaround of hard-coding the password in code, but I guess that is not possible... – Lukap Dec 23 '11 at 11:22
  • If you do not provide password then you will have no protection for sending emails. I think you can create your own email server without the password protection of your accounts but it is likely that your server will be used for spam. – Yury Dec 23 '11 at 11:39
1

You can ask the user password one time and then store it in your internal storage. It may be necessary to add a way to change the password later if preferred. Deciding from documentation, the internal storage is even secure, while it is also possible to use additional encryption. This is how most of E-mail clients work.

Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93