Skip to Main Content
JavaMail API
book

JavaMail API

by Elliotte Rusty Harold
July 2013
Intermediate to advanced content levelIntermediate to advanced
95 pages
2h 15m
English
O'Reilly Media, Inc.
Content preview from JavaMail API

Chapter 1. Introducing the JavaMail API

The JavaMail API is a fairly high-level representation of the basic components of any email system. The components are represented by abstract classes in the javax.mail package. For instance, the abstract class javax.mail.Message represents an email message. It declares abstract methods to get and set various kinds of envelope information for the message, such as the sender and addressee, the date sent, and the subject. The abstract class javax.mail.Folder represents a message container. It declares abstract methods to retrieve messages from a folder, move messages between folders, and delete messages from a folder.

These classes are all abstract because they don’t make many assumptions about how the email is stored or transferred between machines. For instance, they do not assume that messages are sent using SMTP or that they’re structured as specified in RFC 822. Concrete subclasses of these classes specialize the abstract classes to particular protocols and mail formats. If you want to work with standard Internet email, you might use javax.mail.MimeMessage instead of javax.mail.Message, javax.mail.InternetAddress instead of javax.mail.Address, and com.sun.mail.imap.IMAPStore instead of javax.mail.Store. If you were writing code for a Microsoft Exchange-based system, you’d use different concrete implementation classes but the same abstract base classes.

The JavaMail API roughly follows the abstract factory design pattern. This pattern allows ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Scripting in Java: Integrating with Groovy and JavaScript

Scripting in Java: Integrating with Groovy and JavaScript

Kishori Sharan
Spring Boot 2.0 Projects

Spring Boot 2.0 Projects

Mohamed Shazin Sadakath

Publisher Resources

ISBN: 9781449367237Errata Page