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 settings.

StepsAdding a JavaMail session in EAServer

  1. From the Web Management console, expand the Resources folder, right-click the Mail Sessions folder, and select Add.

  2. Follow the wizard instructions to add the JavaMail session.

  3. Click Finish when done, then define the properties for this mail session.

StepsDefining the properties for a JavaMail session:

  1. From the Web Management Console, expand the Resources folder, and expand the Mail Sessions folder. Select the mail session for which you are defining the properties.

  2. Configure the mail session’s properties by selecting these tabs:

    • General

    • POP3

    • POP3S

    • SMTP

    • SMTPS

    These properties map directly to the properties listed in Appendix A of the JavaMail specification. When the name service has a binding for an object of type javax.mail.Session, an instance of the com.sybase.djc.mail.MailSession component is created and calls a getMailSession method on it. The method creates a new javax.mail.Session, passing in the mail properties which you have defined. The method returns the newly created javax.mail.Session to be bound in the name service.

  3. Click Apply.