In this article, the first in a multi-part series, you will learn the basics of Java Mail and how to use it for data exchange. This article covers the concepts surrounding different mailing protocols, the APIs that form the basis of Java Mail, and the creation of a class containing common email-related functionalities.
Java Mail API: Getting Started - Mail Protocols: Rules that Govern Email (Page 2 of 4 )
Protocols are rules that define an exact format for communication between systems. In the case of mailing systems, there are four main protocols:
Let's take a look at each of them.
SMTP, short for Simple Mail Transfer Protocol, defines a mechanism for delivery of email. Any email client, to transfer mail, contacts the SMTP server of the organization that, in turn, delivers the message to the recipientís SMTP server. The recipient extracts the message using POP or IMAP. In essence, SMTPís function is only to deliver the message.
It is acronym for Post Office Protocol. It is currently in its third version, known as POP3. Most of the mail servers use this protocol to provide the delivered messages to the user. In reality POP3 just ensures that each user has his or her own mailbox.
IMAP stands for Internet Message Access Protocol. While POP is for offline access of messages, IMAP is for online access. In other words, when POP is used for accessing the messages, they are offloaded from the server, whereas in the case of IMAP, they are accessed on the server itself. In essence, IMAP allows a client application to access a remote message repository as if it were local. When compared to POP, IMAP taxes the server heavily.
Multipart Internet Mail Extension, or MIME for short, is not about delivery or storage of messages. It is about the attachment and type of content being delivered.
When working with Java Mail API, one doesnít have to worry about which of these have to be supported, because they can be plugged in any time in the future. Now that the protocols have been introduced, let's move on to the next section.