Most of todays advanced business applications, in one way or another, use email. E- commerce applications use email to provide order confirmation and shipping information to online shoppers. Client/server applications use email to deliver software updates. Internet- enabled legacy applications use email to deliver reports. Email has proven to be a more efficient communications device than the old-fashioned phone call. Everyone has email, especially today with free email hosts such as Hotmail and Juno available. It stands to reason, therefore, to integrate email into your business applications. The problem is finding an email service provider. Many of those email service providers are costly; for instance, IBM will tell you to use Domino as your email service provider. Another problem is that the interfaces to these email service providers are often complex and dissimilar.
Sun Microsystems has been solving the problems of inconsistent interfaces and platform- and vendor-specific implementations of common computing strategies. First, it developed Java as a cross-platform language, and, then, it built standard Java interfaces for universal software requirements. These standard interfaces include such things as JavaBeans, Java Database Connectivity (JDBC), and Enterprise JavaBeans (EJBs). Application developers are now able to mix and match software components provided by various vendors. One of the standard interfaces designed by Sun is JavaMail.
The Standard Email API
Like the other Java APIs, JavaMail is merely a standard list of methods encapsulated in an object-oriented framework that provides an intuitive interface that shields the user from the complexity of its implementation (which, in this case, is four email protocols). To use JavaMail, you need servers that are capable of sending and receiving messages. The two protocols commonly used to send messages are Simple Mail Transfer Protocol (SMTP) and Multipurpose Internet Mail Extension (MIME). The protocols for receiving messages are POP3 and Internet Mail Access Protocol 4 (IMAP4). (JavaMail, by the way, uses another Sun Microsystems framework, JavaBeans Activation Framework [JAF], to get to an
emails message text and attachments.) Using the IP address of your operating systems or ISPs SMTP, POP3, and IMAP4 servers, you can integrate email into your applications with JavaMail.
Reference Implementation
JavaMail, similar to ODBC and JDBC, is just an interface; you must obtain the implementation of that interface from a service provider. That suggests that youre going to have to pay a vendor for a JavaMail service provider. Sun Microsystems, however, provides a reference implementation of JavaMail. Reference implementations is what Sun calls its freeware implementations of its various frameworks. Sun provides these reference implementations for you so that you might develop and test proof-of-concept applications. My point is that you dont have to wait for JavaMail service providers; you can integrate email into your Internet applications today with Suns reference implementation of JavaMail.
JavaMail is available on Suns JavaMail Web page at java.sun.com/products/javamail/index.html. (Be sure to also download JAF from Suns JAF page at java.sun.com/beans/glasgow/jaf.html. The framework makes it easy to create a cross-platform mail application without in-depth knowledge of email.) To show you how easy it is to use JavaMail and to prove that JavaMail is cross-platform, Suns downloadable files include an example application, msgsendsample.java, that sends a simple message to an email address provided as a parameter. For instance, to send an email to Joe Hertvik from my AS/400, I invoke the msgsendsample Java class from the AS/400s Qshell command environment with the following statement:
java msgsendsample
smtp1.attglobal.net true
The first parameter to the msgsendsample Java app is the to email address, and the second parameter is the from address. The third parameter, smtp1.attglobal.net, is the address of an SMTP server, and the fourth parameter value, true, asks the application to display debug information. If you look at the code for the msgsendsample Java class,
youll see how easy it is to use the JavaMail API. The JavaMail package contains Java classes that contain methods/functions that are intuitive to use. For instance, the Message class has methods called setFrom, setRecipients, setSubject, setSendDate, and setText.
Besides send-mail capabilities, JavaMail also provides classes for retrieving email. To use those classes, you will need to provide the IP address of a POP3 or IMAP4 service provider (note that Sun provides a Java-based reference implementation of POP3). JavaMails Store class has methods called connect and getFolder that allow you to connect to the server and retrieve a Folder object. You can then use the returned Folder objects getMessages method to retrieve all email (as a Message object) in a folder.
Click Here for More on JavaMail
The JavaMail API, by itself, is really not that impressive; after all, its just an API with no code behind it. But what is impressive is that numerous vendors are providing implementations for the cross-platform JavaMail API. To find out whos using JavaMail today, visit Suns Third-Party Products for JavaMail page at java.sun.com/products/javamail/Third_Party.html. For more information on SMTP, see the SMTP request for comments (RFC) 821 specification at info.internet.isi.edu/innotes/rfc/files/rfc821.txt. For more information on IMAP and POP3, download the Message Access Paradigms and Protocols Web page at ftp://ftp.cac.washington.edu/mail/imap.vs.pop.
LATEST COMMENTS
MC Press Online