« postfix and no worth... | Main | Eclipse: maven insta... »

Using JNDI and JavaMail with SMTP auth

Today I stumbled into a problem configuring a SMTP Mail session in Glassfish to be used out from my EJB.

My SMTP Host requires an authentification with a username and a special password.

Using the javax.mail.api the following params are responsible for a authenticated connection.

mail.smtp.host
mail.smtp.user
mail.smtp.password


The problem is that these params can not be read - or better will not be provided to the configured mail session in glassfish.

Here is a bugreport which explains the problem and show how the params need to be named:

https://glassfish.dev.java.net/issues/show_bug.cgi?id=4515

also there is a useful thread which a general descussion how to establish a authenticated smtp session:

http://forums.sun.com/thread.jspa?threadID=615393&start=0&tstart=0

So the smtp params in glassfish need to be renamed as followed:

mail-smtp.host
mail-smtp.user
mail-smtp.password