if (details.getSubject() == null || !BooleanUtils.xor(ArrayUtils.toArray(details.getMessage() != null, details.getMessageTemplate() != null))) {
throw new IllegalStateException("Either subject or subjectKey / either template/message/messageKey should be specified");
}
Validate.notBlank(details.getFrom());
Email email = createEmail(details.isHtml());
String subject = constructSubject(details);
email.setSubject(subject);
String emailMessage = constructEmailMessages(details);
try {
if (details.isHtml()) {
((HtmlEmail) email).setHtmlMsg(emailMessage);
} else {
email.setMsg(emailMessage);
}
for (String to : details.getTo()) {
email.addTo(to);
}
email.setFrom(details.getFrom());
email.send();
} catch (EmailException ex) {
logger.error("Exception occurred when sending email to " + details.getTo(), ex);
}
}