Bamboo 4.4 : Setting up JNDI mail on JBoss 4.2.2

This page explains how to set up the (gmail) mail service for JBoss 4.2.2. with the following features

  • smtp over SSL
  • TLS encryption

After installing bamboo.war on jboss modify <jboss-install>/server/default/deploy/mail-service.xml to be

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: mail-service.xml 62349 2007-04-15 16:48:15Z dimitris@jboss.org $ -->
<server>

  <!-- ==================================================================== -->
  <!-- Mail Connection Factory                                              -->
  <!-- ==================================================================== -->

  <mbean code="org.jboss.mail.MailService"
         name="jboss:service=Mail">
    <attribute name="JNDIName">java:/Mail</attribute>
    <attribute name="User">${account}@gmail.com</attribute>
    <attribute name="Password">${pw}</attribute>
    <attribute name="Configuration">
      <!-- A test configuration -->
      <configuration>
        <!-- Change to your mail server prototocol -->
        <property name="mail.transport.protocol" value="smtp"/>

        <!-- Change to the user who will receive mail  -->
        <property name="mail.user" value="${account}@gmail.com"/>

        <!-- Change to the SMTP gateway server -->
        <property name="mail.smtp.host" value="smtp.gmail.com"/>
        
        <!-- The mail server port -->
        <property name="mail.smtp.port" value="465"/>
        
        <!-- Change to the address mail will be from  -->
        <property name="mail.from" value="${account}@whatever.com"/>
        
        <property name="mail.smtp.auth" value="true"/>
        <property name="mail.smtp.user" value="${account}@gmail.com"/>
        <property name="mail.smtp.password" value="${pw}"/>
        <property name="mail.smtp.ssl.enable"  value="true"></property>
        <property name="mail.smtp.socketFactory.class"  value="javax.net.ssl.SSLSocketFactory"></property>
        <property name="mail.smtp.starttls.enable" value="true"/>

        <!-- Enable debugging output from the javamail classes -->
        <property name="mail.debug" value="false"/>
      </configuration>
    </attribute>
    <depends>jboss:service=Naming</depends>
  </mbean>

</server>

Problems

If you encounter a class loading problem you will need to remove

  • <bamboo-war>/WEB-INF/lib/activation-x.x.x.jar
  • <bamboo-war>/WEB-INF/lib/mail-x.x.x.jar

from bamboo.war to avoid the clash with jboss' native libraries.