-2

Is there way to send email through JavaMail without implicity setting password in Java code (or properties file)?

3
  • 4
    What do you mean by "without implicity seting email in java code"? Do you mean, the email address?
    – Vikdor
    Aug 19, 2012 at 19:12
  • 1
    Maybe a bit more clarification as to the problem would help, or a short SSCCE would get you better help faster Aug 19, 2012 at 19:22
  • If you mean "without explicitly supplying a password", see this answer: stackoverflow.com/questions/12839132/… Aug 21, 2013 at 11:49

1 Answer 1

3

I assume that by "without implicity setting password in Java code " you mean "without hardcoding the password such that others can see it".

If your SMTP server requires a password then the client program (the one sending the emails) must provide it, and get it from somewhere. The three choices are

  1. Hardcode in Java
  2. Store in Properties file
  3. Provide manually on startup

That's about it. If your client is not running in a secure environment (where you control who has access to the properties file) it probably shouldn't be accessing a secure service in this fashion.

One possible alternative is to write your own intermediate service. The client connects to your service, which can examine and discard anything inappropriate, and which connects to the real email server (with the password) only for those send attempts that pass verification. Your service wouldn't need to implement SMTP; it could be a simple POST servlet.

Not the answer you're looking for? Browse other questions tagged or ask your own question.