Show TOC Start of Content Area

Procedure documentation Creating Secure Connections Using JavaMail  Locate the document in its SAP Library structure

Use

Applications that use the JavaMail Client Service can create secure communication with mail servers. If you choose to establish a secure connection instead of a plain one, the connection will be encrypted and the client and server will be required to authenticate themselves with certificates.

Procedure

1. Configure the Mail Client's Authentication Certificate

...

                            a.      Supply a custom certificate in the secure store.

More information: Using the AS Java Key Storage

Note

The supplied certificate must be acceptable by the mail server.

                            b.      Set the path to that certificate as a value of the sslCertificate property of the JavaMail Client Service. By default, the value of that property is a test certificate, installed in the secure store.

Recommendation

We recommend that you do not use the default certificate. You have to change the value to point to the real authentication certificate.

More information about managing service properties: Java System Properties

 

2. Define the Secure Connections Programmatically

Basically, the procedure requires that you supply the S-protocols (SMTPS, POP3S and IMAPS) instead of the plain ones.

To establish a secure connection with the corresponding server, pass a modified parameter to the getTransport or the getStore methods of the Session object respectively in the following way:

 

The following code example illustrates how to establish secure connections.

Syntax

Transport tr = ses.getTransport("smtps"); 

//…

//Send the e-mail messages in the standard way

Store store = ses.getStore("pop3s");

store.connect("myHost.my", "user", "pass");

//…

//Receive e-mail messages from the server in the standard way

 

 

 

End of Content Area