Introducing the Messaging Access SDK
Table of Contents | Previous | Next | Index

Messaging Access SDK Guide
Part 1. Using the Messaging Access SDK


Chapter 1
Introducing the Messaging Access SDK

The Netscape Messaging Access software development kit (SDK) provides a set of Protocol Level APIs that the developer can use to write messaging applications and extend applications with messaging services. This chapter is an overview of the Messaging Access SDK, version 3.5.

The Messaging Access SDK provides SMTP, MIME, POP3, and IMAP4 APIs in the Java and C programming languages, for a variety of platforms.

The Messaging Access SDK Guide provides developers with a complete set of software libraries, sample code, and documentation for building mail-enabled applications.

[Top]

How the Protocol APIs Work Together

The Messaging Access SDK provides implementations of the Internet messaging protocols, SMTP, IMAP4, MIME, and POP3. These Protocol APIs are designed to work together, yet have the ability to operate independently of each other.

SMTP (Simple Mail Transfer Protocol). SMTP sends non-encoded or MIME-encoded messages. You can use MIME to prepare to send messages in formats other than text, to encode messages, and to include attachments. For more information, see Chapter 2, "Sending Mail with SMTP."

MIME (Multipurpose Internet Mail Extension). MIME builds and encodes messages with attachments for sending with SMTP, and parses and decodes received messages. The encoded MIME message is passed to SMTP.

The MIME API consists of the MIME encoder and the MIME parser. The MIME encoder is used to build MIME messages with attachments and encode them for sending over SMTP. You can use the MIME API to parse and decode messages when they are received through IMAP4 or POP3. For more information, see Chapter 3, "Building and Parsing MIME Messages."

IMAP4 (Internet Message Access Protocol, version 4). IMAP4 is used to retrieve and manage messages remotely. The user can save messages on the server or locally. In addition, the user can manipulate items on the server (for example, create or delete mailboxes). IMAP4 supports multiuser mailboxes. For more information, see Chapter 4, "Receiving Mail with IMAP4."

POP3 (Post Office Protocol, version 3). POP3 connects to the server and retrieves messages. POP3 is simpler than IMAP4 and provides a subset of its capabilities. It supports one user per mailbox. For more information, see Chapter 5, "Receiving Mail with POP3."

For a quick reference to the Internet Protocol commands called by Messaging Access SDK methods, see Chapter 6, "Reference to Protocols."

The Protocol APIs are designed to co-exist in the same client environment and match each other's interfaces where applicable. For example, the message data chunks returned by POP3 and IMAP4 APIs can be fed to the MIME SDK API to parse the message contents. In the same way, the encoded message byte-stream returned by the MIME API can be passed to the SMTP API to transmit the message. At the same time, the APIs are designed to allow customers to use only the API required by their application.

Applications written with the Messaging Access SDK Protocol APIs can work with any messaging system that implements the Internet messaging protocols, primarily the Netscape Messaging Servers. Protocol APIs are self-contained and are intended to coexist with all other SuiteSpot SDKs; they are independent of Netscape Server releases.

Each Messaging Access SDK Protocol API is designed to follow its Internet standard specification. API invocations result in the exchange of standard protocol elements with the server. Any information exchange with the server conforms to one of the standard protocols.

Figure 1.1   Messaging Access API Architecture

The Messaging Access SDK is designed to parse and format protocol elements and make these available to the programmer through Java classes or C data structures and the methods and functions that access them.

The Messaging Access SDK Protocol APIs are built to be thin and are optimized for performance and memory. Each Protocol API includes a sendCommand (or pass-through) interface, which programmers can use to send protocol elements that are not directly supported by the API. The IMAP4 API has further conveniences, such as transparently handling unilateral and unsolicited responses from the server and making these available at the API level through a callback mechanism.

For more information about the sendCommand API, see the reference entries for SMTPClient.sendCommand, POP3Client.sendCommand, and IMAP4Client.sendCommand.

For more information about using callbacks, see the section about callback mapping in each of these chapters: Sending Mail with SMTP, Receiving Mail with IMAP4, Receiving Mail with POP3, and Building and Parsing MIME Messages.

[Top]

The Messaging Access SDK, Java Version

The Messaging Access SDK (Software Development Kit) comes in a zip file on Unix and a self-extracting executable on MS Windows.

You can download the SDK at this URL.

For the latest installation information, see the ReadMe file for the SDK.

The Messaging Access SDK download file contains the following directories and files:

On Unix, unzip the downloaded file using a utility that preserves the file hierarchy, for example, gzip. On MS Windows, simply execute the self-extracting executable. For links to the latest information about installation, see ReadMeJ.htm, included in the SDK.

[Top]

Supported Platforms

The Messaging Access SDK supports the MS Windows and Unix platforms listed in Table 1.1.

Table 1.1 Supported Platforms

Platforms Supported Versions

Solaris

2.5.1, 2.6

Windows NT

4.0 with SP 3

Windows 95

AIX

4.21

IRIX

6.2

OSF/DEC Unix

4.0d

HP-UX

11.0

[Top]


SDK Sink Classes for Java

The SMTP, IMAP4, and POP3 response sinks and the MIME data sink are Java interfaces that contain callback methods for each client call. These Java interfaces contain method definitions and opaque data.

For easy reference, each protocol chapter includes a table that shows how its methods are mapped to callbacks. See the individual protocol chapters under "Method Callback Mapping."

When you start a session with SMTP, IMAP4, or POP3, you first create (initialize) the response sink. Then you create the client, which calls the response sink methods. To use the client object, you must implement the response sink interface, as the constructor for the client class takes a sink object as a parameter. The response sink receives and processes all the available server response data whenever the processResponses call of the client class is issued. This call reads in responses from the server and invokes the appropriate callback method for all responses that are available at the time of execution.

When you start a session with the MIME dynamic parser, you first create and initialize the data sink, and then you create the parser. The parser makes callbacks to its data sink based on the kind of data it finds in the input stream. For example, if it finds a header, it makes the header callback. For the other protocols, the callback comes from the server and callbacks tend to be tied to individual methods.

For MIME, the kind of callback is dependent upon the kind of data that is in the input stream. There are no particular correspondences between functions and data sink callback prototypes, as there are in the other protocols.

As a convenience, SMTP, IMAP4, and POP3 provide sink classes that implement the response sink interface. For example, the SMTPSink class implements the ISMTPSink interface. You can save a step by extending the sink class, or you can implement your own class based on the interface.

For more information, see the section about implementing the response sink in each of these chapters: Sending Mail with SMTP, Receiving Mail with IMAP4, Receiving Mail with POP3, and Building and Parsing MIME Messages.

NOTE: SMTP, IMAP4, and POP3 commands are asynchronous. After sending a command, the application does not have to wait to issue the next one, but can do something else. §
[Top]

SDK Exceptions for Java

In general, the Messaging Access SDK uses standard Java exception handling for dealing with unexpected occurrences during processing. In addition, it provides several exception classes.

Messaging Access SDK Exceptions
Protocol Exceptions handle internal errors in the protocol implementation of the Messaging Access SDK. These exceptions can be thrown when an error is detected within the SDK (on the client side) or when data received from the server results in a parsing error. Exception classes: SMTPException, MIMEException, POP3Exception, IMAP4Exception, IMException.

Protocol Server Exceptions handle server response errors. These exceptions are caused when the server sends an error saying that some part of the operation failed or is not supported. This can happen even when all relevant code executes properly and everything operates normally on the client side.

Server Exceptions are thrown from the error callback on the response sink when an API call that is mapped directly to the RFC fails. It is up to the developer to determine whether or not the error callback will throw this exception. As an SDK default, the SMTP, IMAP4, and POP3 sink classes that represent the response sink classes throw an exception whenever the error callback is called. Server Exception classes: SMTPServerException, POP3ServerException, IMAP4ServerException.

Standard Java Exceptions
IOException exceptions handle I/O errors, which usually occur when the user tries to make API calls before connecting or if the connection is lost unexpectedly. The user can respond by catching the IOException and examining the reason for the failure. The user can try to re-establish the connection by calling connect again.

InterruptedIOException exceptions occur when a time-out occurs. This is a recoverable condition; the application can wait and reissue the method.

[Top]

Compiling with the Java SDK

Follow these steps to compile the Java version of the Messaging Access SDK. These instructions assume you have already set up your Java development environment. If not, you can download the JDK 1.1.5 (Java Development Kit) from the Java web site.

The Java version of the Netscape Messaging SDK comes with two Java Archive (JAR) files.

When you install the Netscape Messaging Access SDK, these files are copied into the packages subdirectory under the install-root directory.

Setting the CLASSPATH

You must set the CLASSPATH environment variable to include the fully qualified path names for the proapi.jar and the coapi.jar files.

On Unix platforms, set the CLASSPATH as follows:

If you are using ksh:

%
CLASSPATH=$CLASSPATH:<fully-qualified-path>/proapi.jar: 
                     <fully-qualified-path>/coapi.jar
% export CLASSPATH 
For convenience, consider adding the lines above to your .profile file.

If you are using csh:

% set classpath=($classpath <fully-qualified-path>/proapi.jar 
                            <fully-qualified-path>/coapi.jar)
For convenience, consider adding the lines above to your .cshrc file.

On MS Windows platforms, set the CLASSPATH as follows:

C:\> set
CLASSPATH=%CLASSPATH%;<fully-qualified-path>\proapi.jar;
                      <fully-qualified-path>\coapi.jar
If you are using MS Windows 95, consider adding these lines to your AUTOEXEC.BAT file.

If you are using MS Windows NT, make these environment variable changes in the Control Panel. To do this, start the Control Panel, select System, and then edit the environment variables.

NOTE: If you are not using the Sun JDK, you may need to make other environment changes as specified by the vendor. For example, if you are using Symantec Visual Cafe 2.0, you must set the CLASSPATH in the sc.ini file in the bin directory. §
If your environment requires it, set your PATH variable to include the target directory for building your Java application.

After you have set up your environment, you can build an application that uses the Messaging Access SDK API by invoking the javac compiler on the Java files you want to compile. For example, if you are using the Sun JDK, you could use this code:

cd <build-directory>;  javac *.java 
If you are using another environment, such as Symantec Visual Cafe, follow the build procedure for that environment.

[Top]


Table of Contents | Previous | Next | Index

Last Updated: June 3, 1998

Copyright © 1998 Netscape Communications Corporation