Java Mail API: Getting Started
(Page 1 of 4 )
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.
Communication is the backbone of any enterprise. Communication, without exchange of data, is unimaginable. In the context of communication between Enterprise level applications, the amount of data would be huge. So using traditional approaches in Electronic Data Interchange wouldn’t suffice.
If one ponders over the other options viable in this context, especially in the area specific to J2EE, there are a few. These include the Java Messaging Service (or JMS for short) that can transfer data up to 4 M.B in size. But what doesn’t get mentioned is the existing set of APIs that were primarily designed for the purpose of exchanging amount of data up to 15 MB. These APIs constitute Java Mail APIs.
The design goal was to develop a set of interfaces that would help in setting up an emailing environment. But the interfaces were such that the data could be sent not only to mail servers, but also to any server capable of understanding mail protocols. That brought almost every J2EE server into the picture. Thus APIs created for mail exchange provided a means to exchange huge amounts of data.
In this two part article I will be discussing the basics of Java Mail and using them for data exchange. In this article, which is the first part, I will focus on the basics. The concepts surrounding different mailing protocols will be discussed in the next section. The section after that will cover the APIs that form the basis of Java Mail.
In the final section I will put it all together to create a class containing common functionalities such as connecting to a server, getting the messages and logging out. The server I will be using is Apache James, as it comes preconfigured for mailing purposes. Though any server could be used, the reason for using James, especially for experimenting purposes, is that when other J2EE servers are used, they have to be configured. In the case of Apache James, the configuration is as simple as unpacking and setting up the environment variables. It also provides a good number of examples to help you understand the working of the mail API. So now, let’s get started with the Java Mail API.
Next: Mail Protocols: Rules that Govern Email >>
More Java Articles
More By A.P.Rajshekhar