Anyone can write his own implementation of the JavaMail API, to interact with these
or other protocols. The document titled “The JavaMail Guide for Service Providers” is
packaged with the JavaMail archive and specifies how to develop and package a ser-
Preparing to Use JavaMail
Before you get started using JavaMail, you probably want to know what you will need to use
the JavaMail API, and where to locate it. The JavaMail API can be downloaded from
The archive you will get contains the JavaMail API jar file, all of the javadoc files, the
JavaMail Specification in PDF format, the guide for service providers in PDF format, and a
decent collection of demo code with documentation.
JavaMail makes extensive use of the JavaBeans Activation Framework (JAF), so you will also
need to download this Java extension. It can be found at
This archive contains a collection of files similar to the JavaMail archive. The two important
files you will need are mail.jar and activation.jar . Both of these archives must be added
to your classpath before you can begin working with JavaMail.
A JavaMail Example
Let's walk through a simple example of sending a message using JavaMail.
The JavaMail API provides an interface to perform many more complex tasks, includ-
ing sending MIME-encoded attachments with your mail. And, as we discussed earlier,
you can retrieve and manipulate messages from your mailboxes. The demo code that
accompanies JavaMail gives good examples of some of the other features that you
can use. With a little creativity, you are not limited in what you can accomplish.