logger.error("RegisterUser: the email of user " + user.getUsername() + " is not defined");
addActionError(String.valueOf(ActionErrorCode.ERROR_EMAIL_UNDEF));
return false;
}
SimpleMailMessage notifyMsg = new SimpleMailMessage(getNotifyEmailTemplate());
notifyMsg.setTo(toUserEmail);
if(notifyMsg.getFrom() == null){
String contactEmail = getGnizrConfiguration().getSiteContactEmail();
if(contactEmail != null){
notifyMsg.setFrom(contactEmail);
}else{
notifyMsg.setFrom("no-reply@localhost");
}
}
SimpleMailMessage approvalMsg = new SimpleMailMessage(getApprovalEmailTemplate());
if(toAppvEmail != null){
approvalMsg.setTo(toAppvEmail);
approvalMsg.setFrom(toUserEmail);
}else{
logger.error("RegisterUser: siteContactEmail is not defined. Can't sent approval emaili. Abort.");
return false;
}
Template fmTemplate1 = null;
Template fmTemplate2 = null;
String text1 = null;
String text2 = null;
try{
fmTemplate1 = freemarkerEngine.getTemplate("login/notifyemail-template.ftl");
fmTemplate2 = freemarkerEngine.getTemplate("login/approvalemail-template.ftl");
text1 = FreeMarkerTemplateUtils.processTemplateIntoString(fmTemplate1,model);
text2 = FreeMarkerTemplateUtils.processTemplateIntoString(fmTemplate2,model);
}catch(Exception e){
logger.error("RegisterUser: error creating message template from Freemarker engine");
}
notifyMsg.setText(text1);
approvalMsg.setText(text2);
if(getMailSender() == null){
logger.error("RegisterUser: mailSender bean is not defined");
addActionError(String.valueOf(ActionErrorCode.ERROR_CONFIG));
return false;