Using JavaMail with Domino

     

The JavaMail package ( javax.mail ) provides a set of interfaces for creating and sending e-mail messages to various types of mail providers. JavaMail can be configured to send e-mail messages to providers that support the Internet standard Simple Mail Transfer Protocol (SMTP). SMTP is one of the e-mail protocols supported by the Domino server. Thus, it is common in combined WebSphere and Domino-based applications to use JavaMail to generate e-mail within J2EE Web applications and have it handled by the Domino server. Fortunately, this approach works with relatively little configuration required for either the JavaMail package or for Domino.

One of the default e-mail provider implementations supplied with JavaMail is for SMTP providers. Since WAS is built on J2EE versions that include JavaMail, WAS is capable of supporting JavaMail applications using SMTP. Moreover, WAS (V5 and above) itself supports the configuration of JavaMail sessions via its Web administration application. With former versions of JavaMail, the provider configurations were made via Java properties files, which were usually built within the application itself. With the newer JavaMail versions, the JavaMail sessions are preconfigured and obtained by the application via JNDI lookup. It's this preconfigured JavaMail session approach that is now used in WAS.

To define a preconfigured JavaMail session via the WAS Web administrative console, expand the Resources item in the left-hand pane of the console and select Mail Providers . Select Server as the resource scope (see Figure 10-12); then click the Apply button. Select the Built-in Mail Provider preference page and then open the Mail Sessions properties page from the link at the bottom of this page (see Figure 10-13).

Figure 10-12. WAS Admin Mail Providers page 1.
graphics/10fig12.gif

Figure 10-13. WAS Admin Mail Providers page 2.
graphics/10fig13.gif

The Mail Sessions properties page allows you to specify a name and JNDI name for this SMTP mail session resource. The JNDI name is used in the application to refer to this resource. You also specify the properties to be used to connect to the SMTP provider on this page, such as the Mail Transport Host, User ID , and Password (see Figure 10-14). Once this resource is saved, it can be used by the Web application.

Figure 10-14. WAS Admin Mail Providers page 3.
graphics/10fig14.gif

On the Domino server side, you must configure Domino as an SMTP listener. This is done in the Server document in the Domino directory by enabling the SMTP protocol for the server. If the e-mail messages are directed to addresses within the Domino domain, you must ensure that the recipient addresses exist in the Domino directory (either in the primary names .nsf database or in external directories adjoined via the Directory Assistance feature). Also ensure that the Internet domain name used for these recipient addresses matches the Internet domain name specified for the server in the Server document.

Once WAS and Domino have been configured for SMTP interchange, you can then add JavaMail classes and invocations to your Web application in a straightforward manner. There are many references available on using the JavaMail package from within a J2EE application (for example, java.sun.com), but we will not go into the details of the JavaMail API here.



IBM WebSphere and Lotus Implementing Collaborative Solutions
IBM(R) WebSphere(R) and Lotus: Implementing Collaborative Solutions
ISBN: 0131443305
EAN: 2147483647
Year: 2003
Pages: 169

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net