Sending mail through java requires password which expires every month

I wrote a code that sends mail through javax.mail. But it requires authentication.And the password of the mail account needs to be changed every month.So if I hard code the password in code,I will have to manipulate the code every month. Is there any way to sort it out?

Any Help would be appreciated!!

There is a number of solutions. The easiest ones are:

  • either keep your password in property file (not secure enough unless you implement some encryption mechanisms)
  • or propagate the password to your code as a command line parameter or an environment variable.