LOG.debug("Sending mail to " + emailAddress);
if(!configuration.isEmailTransportEnabled()) {
throw new TransportConfigurationException("Email transport is not enabled!");
}
Email email = new SimpleEmail();
email.setHostName(configuration.getEmailTransportHostname());
email.setSmtpPort(configuration.getEmailTransportPort());
if (configuration.isEmailTransportUseSsl()) {
email.setSslSmtpPort(Integer.toString(configuration.getEmailTransportPort()));
}
if(configuration.isEmailTransportUseAuth()) {
email.setAuthenticator(new DefaultAuthenticator(
configuration.getEmailTransportUsername(),
configuration.getEmailTransportPassword()
));
}
email.setSSLOnConnect(configuration.isEmailTransportUseSsl());
email.setStartTLSEnabled(configuration.isEmailTransportUseTls());
email.setFrom(configuration.getEmailTransportFromEmail());
email.setSubject(buildSubject(stream, checkResult, configuration, backlog));
StringBuilder body = new StringBuilder();
body.append(buildBody(stream, checkResult, backlog));
email.setMsg(body.toString());
email.addTo(emailAddress);
email.send();
}