Java Mail API and its application--implementation of a mailing list server (i) (posted)

Source: Internet
Author: User
Tags format mail
Server | Mailing List The Java Mail API is one of the latest standard extension APIs developed by Sun to provide Java application developers with platform-and protocol-independent messaging/communication solutions. This article describes the core mechanism of the API and demonstrates its specific usage through a mail forwarding server (mailing list server).



The development of the Java Mail API is a good example of the ongoing effort by Sun to provide Java developers with a common API framework. The promotion of a common framework against vendor-Limited Solutions is a good predictor of an increasingly open development environment.

In the area of email communications, developers (and users) of end applications have been able to purchase the common API framework implementations that are best suited to their needs, while low-level developers can provide effective access to specific messaging services. The significance lies in: Small development groups can focus on developing high-performance client-side mail software, and it's easy to provide it with support in different messaging environments, while large development organizations focus on providing common access support for newly developed enterprise-class messaging services, with rich application software support. The biggest winner is the information system user, which is able to easily integrate products and programs from different vendors as required (performance, investment, etc.). One of the keys to developing a highly reusable open API framework is the emphasis on abstract interface technology, which supports future extensions and optional implementations on the basis of supporting existing standards. This idea is embodied in the Java Mail API. Sun and other developers are providing default implementations and tools for most existing common standards and protocols. The support already available includes at least: POP3, SMTP, IMAP, and so on.

Introduction of Java Mail API

The structure of the Java Mail API itself attests to one of the basic goals of its developers-the amount of software development effort should depend on the complexity of the application itself and the degree of control required by the developer. In other words, the Java Mail API remains as simple as possible. This is amply illustrated by the sample program attached to this article Listserver (and the demo program that the API package brings).

At first glance, the total number of classes owned by the Java Mail API and the relationships between classes can be misunderstood as requiring lengthy learning hours. In fact, once you start using it, you'll find that the API is a simple tool for adding robust messaging/communication support to your application.

The Java Mail API includes a much larger number of classes than the number of classes involved here. The following describes the functions and roles of some of the core classes, based on the process in which each class appears in a typical application:

Javax.mail.Session

Javax.mail.Session is the top-level portal class for the Java Mail API. Its most common method is to control and load the SPI (that is, service Provider implementation) for different mail protocols. such as Javax.mail.Store is obtained through the session class.

Javax.mail.Store

The Javax.mail.Store class implements read, write, monitor, and find operations on specific mail protocols. The Javax.mail.Folder class can be accessed through the Javax.mail.Store class.

Javax.mail.Transport

The Javax.mail.Transport class is also a class provided by the service provider that implements sending messages/messages with a specific protocol.

Javax.mail.Folder

The Javax.mail.Folder class is used to organize messages hierarchically and to provide the ability to access e-mail in the Javax.mail.Message format.

Javax.mail.Message

The Javax.mail.Message class models all the details of the actual email message, such as title, send/Receive address, Date sent, and so on.

Java Mail API and JAF

It is worth mentioning that the Java Mail API actually relies on another Java extension JAF, the JavaBean activity Framework (JavaBean Activation framework). The purpose of JAF is to unify the methods for handling different data formats (whether the data format is simple text or a composite document made up of pictures, sounds, videos, or even other "active" content). In this sense, JAF's role in Java is just as plug-ins do to Web browsers.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.