Mail Session Connections

If you’ve ever ordered a product from a Web site, you’ve probably received an e-mail confirming your order. The ConfirmerBean class demonstrates how to send e-mail from an enterprise bean.

The source code for this example is in the j2eetutorial/examples/src/ejb/confirmer directory. To compile the code, go to the j2eetutorial/examples directory and type ant confirmer.Asample ConfirmerApp.ear file is in the j2eetutorial/examples/ears directory.

In the sendNotice method of the ConfirmerBean class, the lookup method returns a Session object, which represents a mail session. Like a database connection, a mail session is a resource. As with any resource, you must link the coded name (TheMailSession) with a JNDI name. Using ...

Get J2EE™ Tutorial, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.