All methods of JavaMail Library require an instance of MailConnection class as a parameter. This class is used to specify connection details such as name of the mail server, protocol, encryption etc.

By default, the methods of the JavaMail Library will open a new connection on every call, and close the connection before returning the call. If you intend to call several mail operations in a row, you might want to reuse an established connection. In these cases you can use the two methods of the GlobalOperations class.

Figure: The MailConnection Class

JavaMail_MailConnection

Figure: The GlobalOperations Class

MailConnection

Class MailConnection has the following attributes:

Attribute NameDescriptionAllowed Values 
debugSpecifies whether to write additional debug information to the bridgeserver log.trueAdditional debug information is written to the bridgeserver log.
falseNo additional logs (default).
exchangeVersionSpecifies the Microsoft Exchange version. This parameter is mandatory, if protocol is set to exchange, ignored otherwise.2007_SP1 Exchange 2007 Service Pack 1
2010Exchange 2010
2010_SP1Exchange 2010 Service Pack 1
2010_SP2Exchange 2010 Service Pack 2 and higher
hostSpecifies the host name/IP address of the mail server.a valid host name or IP address
keyStoreSpecifies the file name of the key store file used for SSL connections (optional).a valid filename
keyStorePasswordSpecifies the password of the key store (optional).a valid password
passwordSpecifies the user's password.a valid passwordSome SMTP servers allow unauthorized sending, in these cases you may leave it as NULL.
portSpecifies the port of the mail server.a valid port number
protocol

Specifies the protocol used for e-mail retrieval and storage.
Values are not case sensitive.

imapUse the IMAP protocol.
imapsUse IMAP over SSL.
pop3Use POP3.
smtpUse the SMTP protocol.
smtpsUse the SMTPS protocol.
exchangeUse Exchange Web Service (EWS) API.
security

Specifies the encryption protocol.
Values are not case sensitive.

noneNo encryption used.
sslUse SSL encryption.
starttlsUse TLS encryption
timeoutSecondsSpecifies the number of seconds after which a request (send or receive) times out

any positive integer

default is 0, which translates to protocol defaults: infinite timeout for imap(s),pop3,smtp(s), and 100 seconds for exchange

userSpecifies the user account on the mail server.a valid user
verifyHostSpecifies whether for SSL connections the mail server host shall be verified or not (optional).trueVerify the mail server (default).
falseDo not verify the mail server.

GlobalOperations

Method NameParameterDirectionDescription
openConnectionconnectioninEstablishes a connection with the mail server using the provided connection object.
The established connection will be reused whenever the same connection object is used with one of the JavaMail Library methods, until it  is explicitly closed by closeConnection.
closeConnectionconnectioninCloses a connection previously opened by a call to openConnection.
  • No labels