The Application Server includes the JavaMail API. The JavaMail API is a set of abstract APIs that model a mail system. The API provides a platform-independent and protocol-independent framework to build mail and messaging applications. The JavaMail API provides facilities for reading, composing, and sending electronic messages. Service providers implement particular protocols. Using the JavaMail API you can add email capabilities to your applications. JavaMail provides access from Java applications to Internet Message Access Protocol (IMAP)- and Simple Mail Transfer Protocol (SMTP)-capable mail servers on your network or the Internet. It does not provide mail server functionality; you must have access to a mail server to use JavaMail.
To learn more about the JavaMail API, consult the JavaMail web site at http://java.sun.com/products/javamail/index.html
This chapter contains the following section:
To configure JavaMail for use in Application Server, create a Mail Session in the Application Server Admin Console. This allows server-side components and applications to access JavaMail services with JNDI, using the Session properties you assign for them. When creating a Mail Session, you can designate the mail hosts, transport and store protocols, and the default mail user in the Admin Console so that components that use JavaMail do not have to set these properties. Applications that are heavy email users benefit because the Application Server creates a single Session object and makes it available via JNDI to any component that needs it.
To create a JavaMail session using the Admin Console, select Resources > JavaMail Sessions. Specify the JavaMail settings as follows:
JNDI Name: The unique name for the mail session. Use the naming sub-context prefix mail/ for JavaMail resources. For example: mail/MySession.
Mail Host: The host name of the default mail server. The connect methods of the Store and Transport objects use this value if a protocol-specific host property is not supplied. The name must be resolvable to an actual host name.
Default User: The user name to provide when connecting to a mail server. The connect methods of the Store and Transport objects use this value if a protocol-specific username property is not supplied.
Default Return Address: The email address of the default user, in the form: firstname.lastname@example.org.
Description: Provide a descriptive statement for the component.
Session: Deselect the Enabled checkbox if you do not want to enable the mail session at this time.
Additionally, define the following Advanced settings only if the mail provider has been re-configured to use a non-default store or transport protocol:
Store Protocol: Defines the Store object communication method to be used. By default, the Store Protocol is imap.
Store Protocol Class: Provides the Store communication method class that implements the desired Store protocol. By default, the Store Protocol Class is com.sun.mail.imap.IMAPStore.
Transport Protocol: Identifies the transport communication method. By default, the Transport Protocol is smtp.
Transport Protocol Class: Defines the communication method for the transport class. By default, the Transport Protocol Class is com.sun.mail.smtp.SMTPTransport
Debug: Select this checkbox to enable extra debugging output, including a protocol trace, for this mail session. If the JavaMail log level is set to FINE or finer, the debugging output is generated and is included in the system log file. See Setting Custom Log Levels for information about setting the log level.
Additional Properties: Create properties required by applications, such as a protocol-specific host or username property. The JavaMail API documentation lists the available properties.