[ Team LiB ] Previous Section Next Section

Core Classes of the JavaMail API

The JavaMail API contains four packages: javax.mail, javax.mail.event, javax.mail.internet, and javax.mail.search, although all the core classes are found in the top-level javax.mail package.

The following sections outline the core classes of the javax.mail package.

Session

A Session object is both an object factory and a connection to the mail providers. It provides a hook on the security functionality, and is used to access the other objects of the mail API. The Session class is used to define a basic mail session and it's through the Session object that everything else works. You can use an instance of the java.util.Properties class to get information such as the mail server's name, the username, and the password. Setting up a Mail Session in the Administration Console creates an instance of the javax.mail.session class that you can use in all of your email components through a JNDI lookup (more about this in the next section).

Message

The Message class is an abstract class used to define a basic email message. It's used to set the recipient, subject, and content.

Address

The Address class is an abstract class used to define an email address. You'll most often use the subclass InternetAddress to define the recipients and senders.

Transport

The Transport class is an abstract class used to send messages via the SMTP protocol.

Authenticator

The Authenticator class is an abstract class used to obtain authentication to an SMTP host that requests it.

Store

The Store class is an abstract class that represents an email store. It's used to store and retrieve messages based on that store's protocol. The JavaMail API 1.1.3 implements the IMAP4 protocol, whereas later versions implement the IMAP4 and POP3 protocols.

Folder

The Folder class is an abstract class that represents a folder for mail messages.

    [ Team LiB ] Previous Section Next Section