Chapter 35: Creating JavaMail
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.
Defining the local mail server for a JavaMail program:
In EAServer Manager, open the Properties dialog for the Web application that includes the servlet, EJB, or application that contains the JavaMail program.
Select the Resource Refs tab.
Click Add to add a row to the table.
Select javax.mail.Session from the dropdown list in the Type column.
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.
In the Deployment Settings field, type in the name of your local SMTP mail server for outgoing mail.
Provide a description of your JavaMail resource in the Description field.
|Copyright © 2005. Sybase Inc. All rights reserved.|