Show TOC Start of Content Area

Component documentation Using JavaMail  Locate the document in its SAP Library structure

Overview

The JavaMail Client Service provides a client functionality that allows users to add e-mail and news capabilities to applications deployed on AS Java. It implements the client side of the following mail protocols:

      Simple Mail Transfer Protocol (SMTP) – the basic protocol used for sending e-mail messages.

      Post Office Protocol 3 (POP3) – the protocol for retrieving e-mail messages from a remote server.

      IMAP4 – allows a local client to retrieve e-mail message from a remote server.

      Network News Transfer Protocol (NNTP) – the protocol for newsgroup communication.

It can also establish secure connections over these protocols, using SSL encryption and certificate-based authentication.

The JavaMail Client Service implementation is written in accordance with Sun JavaMailTM API Design Specification 1.4. It uses Sun Microsystems’ provider implementation for the SMTP, POP3 and IMAP4 protocols and its own provider implementation for the NNTP protocol.

The Java Mail Client Service uses mail-activation-iaik library that consists of activation, Java Mail API and implementation, and IAIK SSL implementation components.

Configuring the JavaMail Client Service

The JavaMail Client Service owns a set of properties that allow you to configure the behavior of the service. Using each property is described further in this chapter. Here, they are listed together only as a reference.

You can change these properties using the SAP NetWeaver Administrator.

More information: Java System Properties.

JavaMail Client Service Properties

Property

Default Value

Description

Imap4

localhost

Specifies the host name or address of the IMAP4 server.

Nntp

localhost

Specifies the host name or address of the NNTP server.

Pop3

localhost

Specifies the host name or address of the POP3 server.

Smtp

localhost

Specifies the host name or address of the SMTP server.

mail.from

mymail@sap.com

Specifies the sender of the e-mail message.

mailSessionDebug

false

Specifies if the session object bound to the naming system has the debug option enabled. If you set this property to true, the JavaMail Client Service will log debug information.

sslCertificate

default

Specifies the SSL certificate to be used for authentication if the connection is secure.

The certificate must already be available in the Key Store.

Overview of the Development Process

The mail client functionality is represented by Sun’s Java Mail API.

Usually, you use the Mail Client functionality in session beans. You can also use it in JSP and servlet components. You need to implement the following steps:

...

       1.      Obtain a session object, which represents the client session with the mail server.

More information: Obtaining a Session Object.

       2.      Perform the necessary sending or receiving operations, using the session object. Namely, you can:

       Create an e-mail message with content and additional attributes such as recipients, attachments, and so on.

More information: Creating E-Mail Messages.

       Send the message.

More information: Sending E-Mail Messages.

       Receive e-mail messages.

More information: Receiving E-Mail Messages.

       Create secure connections.

More information: Creating Secure Connections Using JavaMail.

       3.      After finishing with the e-mail operations, destroy the obtained Transport and Store object.

Example

The code extracts listed in this section are taken from the example in the Enabling Java Mail Functionality in Your Applications blog in the SAP Developer Network.

End of Content Area