Deploying JavaMail-enabled applications

If you use JavaMail in Web applications or EJB components, you can configure resource references to alias a JavaMail session to a JNDI name. The resource reference allows you to use JNDI to obtain mail sessions, as described in “Creating a JavaMail session”. The use of logical names allows your application to run in environments where the JNDI namespace does not match the names hard-coded in your application. When you deploy the application, you map the logical names to actual names that match the server’s configuration. You must catalog the JNDI names used by your code in the application’s deployment descriptor. Once your JavaMail-enabled Web application is deployed to a host server, you must configure the javax.mail.Session resource factory reference to the name of the local mail server for that server.

StepsDefining the local mail server for a JavaMail program:

  1. In EAServer Manager, open the Properties dialog for the Web application that includes the servlet, EJB, or application that contains the JavaMail program.

  2. Select the Resource Refs tab.

  3. Click Add to add a row to the table.

  4. Select javax.mail.Session from the dropdown list in the Type column.

  5. The resource reference name in the Name column should be the logical name that refers to the JavaMail resource object and is hard-coded in the JavaMail code. For example, Mail.

  6. In the Deployment Settings field, type in the name of your local SMTP mail server for outgoing mail.

  7. Provide a description of your JavaMail resource in the Description field.

  8. Click OK.