lundi 30 novembre 2009

Configuring JNDI Javamail resource over SSL for SMTP

You declare your JAVAMAIL resource into the server.xml (or in the appropriate context file in your configuration directory) file of your tomcat :

              <Resource name="mail/MailServer" auth="Container"
type="javax.mail.Session"
mail.smtp.host="smtp.mailserver"
mail.smtp.port="465"
mail.smtp.auth="true"
mail.smtp.user="myuser"
password="mypassword"
mail.smtp.starttls.enable="true"
mail.smtp.socketFactory.class="javax.net.ssl.SSLSocketFactory"
/>


Then your resource is accessible via this URI in your webapp :

java:comp/env/mail/MailServer


Also, you must copy the two files
activation.jar and mail.jar in your tomcat common/lib server.

You may refer to the JIRA documentation where I had this hint

http://www.atlassian.com/software/jira/docs/v3.13/smtpconfig.html