private void sendMail(User user, Mails mailType) { MailTemplate mailTemplate = mailTemplateFinder.findByNameAndLocale(mailType.name(), user.getPreferredLocale()); if (mailTemplate == null) { LOG.debug("Mail template " + mailType + " is not configured."); return; } try { Template mailContentTpl = new Template( mailType.name(), mailTemplate.getContent(), new Configuration(Configuration.VERSION_2_3_21)); final StringWriter mailBody = new StringWriter(); mailContentTpl.process(user, mailBody); mailer.sendMail(mailTemplate.getSubject(), user.getLogin(), mailBody.toString()); } catch (Exception e) { LOG.error("Unable to send mail " + mailType + " to user " + user.getLogin(), e); } return; }