}
String apiMessage = null;
SmtpEmailConfig config = apiClient.getSmtpEmailConfig();
EmailMessage message;
if (StringUtils.isNotBlank(config.getRecipientOverride())) {
// This is NOT a "production" request.
message = new EmailMessage(config.getServerName(), config.getPortNumber(), config.getRecipientOverride());
apiMessage = String.format("Request sent to recipient override, %s.", config.getRecipientOverride());
} else {
// This IS a "production" request.
message = new EmailMessage(config.getServerName(), config.getPortNumber(), push.getToAddress());
}
if (config.getAuthType().isTls()) {
message.setAuthentication(AuthenticationMethod.TLS, config.getUserName(), config.getPassword());
} else if (config.getAuthType().isSsl()) {
message.setAuthentication(AuthenticationMethod.SSL, config.getUserName(), config.getPassword());
} else {
message.setAuthentication(AuthenticationMethod.NONE, config.getUserName(), config.getPassword());
}
message.setFrom(push.getFromAddress());
message.send(push.getEmailSubject(), null, push.getHtmlContent());
return apiRequest.processed(apiMessage);
}