Skip to Content
JavaMail API
book

JavaMail API

by Elliotte Rusty Harold
July 2013
Intermediate 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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Professional Java for Web Applications

Professional Java for Web Applications

Nicholas S. Williams
Developing Games in Java™

Developing Games in Java™

David Brackeen, Bret Barker, Laurence Vanhelsuwé
The Kollected Kode Vicious

The Kollected Kode Vicious

George V. Neville-Neil
Modernizing Enterprise Java

Modernizing Enterprise Java

Markus Eisele, Natale Vinto

Publisher Resources

ISBN: 9781449367237Errata Page