Using JavaMail Within J2EE Components
The only complication to using JavaMail within a J2EE component is the restriction that EJBs should not do direct file or network I/O. An EJB relies on the J2EE container to provide required I/O services through objects registered with the name service. You have already seen this in practice with the use of DataSource objects discussed on Day 4, “Introduction to Enterprise JavaBeans.”
To support JavaMail, a J2EE container provides support for resource references to javax.mail.Session objects. Figure 11.4 shows the Admin Console screen for the J2EE RI with a Mail Session object called mail/James representing James email server running on the local workstation.
Figure 11.4. Defining a J2EE RI JavaMail Resource. ...
Get Sams Teach Yourself J2EE™ in 21 Days, Second Edition 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.