private void connect() throws SocketException, IOException, Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("Setting timeout");
LOG.debug("Connecting to SMTP server");
}
String hostname = Property.getProperty(new SystemConfigKey("smtp.hostname"));
int port = Property.getPropertyInt(new SystemConfigKey("smtp.port"));
client.connect(hostname, port);
if (LOG.isDebugEnabled()) {
LOG.debug("Getting reply");
}
int reply = client.getReplyCode();
if (!SMTPReply.isPositiveCompletion(reply)) {
client.disconnect();
throw new Exception("SMTP server refused connection.");
}
if (LOG.isDebugEnabled()) {
LOG.debug("Logging in");
}
String helo = Property.getProperty(new SystemConfigKey("smtp.login"));
if (helo.equals("")) {
client.login();
} else {
client.login(helo);
}