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.