Configuring a Mail Session

Very little needs to be configured to get JavaMail up and running. The basis of configuration is a Mail Session, which holds a global set of mail-related properties that define the behavior of the mail client and network. For instance, you could use the Mail Session to configure the transport protocol to be used, or the particular SMTP server or POP3 server to be used. Later, you can override these settings programmatically when you use the Mail Session.

WebLogic publishes the configured Mail Sessions in its JNDI tree. Each Mail Session must be associated with a JNDI nameonce it's deployed, WebLogic makes the Mail Session available to all clients who need to interact with the JavaMail API. A client program simply performs a JNDI lookup to access the Mail Session, optionally overrides a few session properties, and then uses the Mail Session in a standard way according to the JavaMail API. The only WebLogic-specific configuration is for the Mail Session; for this, you must use the Administration Console.

To create a Mail Session, choose the Services/Mail node from the left pane of the Administration Console, and then select the "Configure a new Mail Session" option. Here you need to supply a name for the Mail Session, a JNDI name by which the Mail Session can be accessed, and a list of property/value mappings. These properties adhere to the JavaMail API specification and are listed in Table 9-1.

Table 9-1. JavaMail configuration properties



Default value

This property defines the protocol that should be used to retrieve email.



This property defines the protocol to be used when sending email.


This property defines the address of the mail server.


This property defines the mail host for a specific protocol. For instance, you can define the host addresses for SMTP and POP3 by creating an entry for and

The value of the property


This property defines the name of the default user that is used when retrieving email. Note that JavaMail does not permit the storing of passwords as properties, so you have to specify this programmatically when contacting the mail host.

The value of the Java system property


The property defines the name of the default user used for the particular protocol.

The value of the mail.user property


This property should be set to the return address of the email and is specified as an email address.



This flag may be set to true to enable output of debugging information.


In general, you should set those properties for the Mail Session that you want all clients to inherit by default. For example, if your clients need to use JavaMail to send emails, the following list of property/value pairs should be sufficient for any client of the Mail Session:

Once the Mail Session has been created, you must target it to the server instances that need access to the session.


Web Applications

Managing the Web Server

Using JNDI and RMI



J2EE Connectors



Using EJBs

Using CMP and EJB QL

Packaging and Deployment

Managing Domains


Performance, Monitoring, and Tuning




Web Services


Logging and Internationalization


WebLogic. The Definitive Guide
WebLogic: The Definitive Guide
ISBN: 059600432X
EAN: 2147483647
Year: 2003
Pages: 187 © 2008-2020.
If you may any questions please contact us: