1. Add the following to your web.xml file (insert it just before </web-app>):
    <resource-ref>
        <description>Test description</description>
        <res-ref-name>mail/Session</res-ref-name>
        <res-type>javax.mail.Session</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
    
  2. Add the following to your server.xml file (anywhere inside the <context ...> tags)
    For Tomcat 5.0.x
    <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
    <ResourceParams name="mail/Session">
        <parameter>
          <name>mail.smtp.host</name>
          <value>mail.example.com</value>
        </parameter>
        <parameter>
          <name>mail.smtp.port</name>
          <value>25</value>
        </parameter>
    </ResourceParams>
    
    For Tomcat 5.5.x and Tomcat 6.x
    <Resource name="mail/Session" auth="Container" type="javax.mail.Session" mail.smtp.host="mail.example.com" mail.smtp.port="25" />
    

    To use the TLS protocol, add the property mail.smtp.starttls.enable="true" to this configuration.

    You only need to specify the mail.smtp.port parameter if you are using a non-standard port for SMTP.
  3. Restart the server. Go to create SMTP mail server screen. For JNDI location, enter:
         java:comp/env/mail/Session