MailConnector

public abstract class MailConnector

MailConnector is an abstract connector for making connection to mail hosts. The configuration of mail connector is mainly through the standard java properties injection. You can always use either addProperties(Properties) or getProperties() to set or get the current configuration of this mail connector. For the detail of the properties key, read here 1.0.1 - Add help method for enabling black box debug mode through setDebug(boolean)

Author:Hugo Y. K. Lam,, Twinsen Tsang (modifers)

Constructors

MailConnector

public MailConnector(String protocol, String host)

Creates a new instance of MailConnector.

Parameters:
  • protocol – the mail protocol.
  • host – the mail host.

MailConnector

public MailConnector(String protocol, String host, String username, String password)

Creates a new instance of MailConnector.

Parameters:
  • protocol – the mail protocol.
  • host – the mail host.
  • username – the user name for authentication.
  • password – the password for authentication.

Methods

addProperties

public void addProperties(Properties properties)

Adds the given mail properties to the underlying mail properties used by this connector.

Parameters:
  • properties – the properties to be added.

addProperty

public void addProperty(String propKey, String propValue)

Adds a property to the underlying mail properties used by this connector.

Parameters:
  • propKey – the property key.
  • propValue – the property value.

createSession

public Session createSession()

Creates a mail session from the underlying mail properties.

Returns:the mail session.

getHost

public String getHost()

Gets the host to which this mail connector connects.

Returns:the mail host.

getIsDebug

public boolean getIsDebug()

Get whether the mail connector is under debug mode.

getProperties

public Properties getProperties()

Gets the underlying mail properties used by this connector.

Returns:the mail properties.

getProtocol

public String getProtocol()

Gets the protocol that this mail connector uses.

Returns:the mail protocol.

setDebug

public void setDebug(boolean on)

Set whether the mail connector is under debug mode.

Parameters:
  • on – The flag whether debug mode is switched on for this mail connector.