The Java Mail API

Although it is nice to be able to write your own Java routines to speak the various email protocols, it can get pretty tedious, too. The SMTPSession and POP3Session classes you saw earlier in this chapter don't handle attachments. Although you could probably add attachments with some work, you don't have to because you have the Java Mail API is at your disposal.

The Java Mail API is a generic mail framework that supports the sending and retrieving of mail messages. The best part is, it supports multiple mail protocols through the same set of objects.

Sending Email with the Java Mail API

The Transport object represents a mail-delivery protocol like SMTP. You can use a Transport object to send Message objects. When you create ...

Get Special Edition Using Java™ 2 Enterprise 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.