Package org.springframework.mail

Examples of org.springframework.mail.SimpleMailMessage


    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
    tokenManager.init();
   
    templateMessage = new SimpleMailMessage();
    templateMessage.setSubject("Email Verification");
   
    notifyMessage = new SimpleMailMessage();
    notifyMessage.setSubject("Account Registration Pending");
   
    approvalMessage = new SimpleMailMessage();
    approvalMessage.setSubject("Account Registration Approval");
   
    mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");
   
View Full Code Here


    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
    tokenManager.init();
   
    templateMessage = new SimpleMailMessage();
    templateMessage.setSubject("Reset Password");

    mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");
   
View Full Code Here

   
    FreeMarkerConfigurationFactory factory = new FreeMarkerConfigurationFactory();
    factory.setTemplateLoaderPath("/templates");
    freemarkerEngine = factory.createConfiguration();
   
    welcomeMessage = new SimpleMailMessage();
    welcomeMessage.setSubject("Welcome");
   
    userManager = new UserManager(getGnizrDao());
    tokenManager = new TokenManager();
    tokenManager.setUserManager(userManager);
View Full Code Here

      logger.error("ApproveUserAccount: the email of user " + user.getUsername() + " is not defined");
      addActionError(String.valueOf(ActionErrorCode.ERROR_EMAIL_UNDEF));
      return false;
    }
   
    SimpleMailMessage notifyMsg = new SimpleMailMessage(getWelcomeEmailTemplate());
    notifyMsg.setTo(toUserEmail);
   
    if(notifyMsg.getFrom() == null){
      String contactEmail = getGnizrConfiguration().getSiteContactEmail();
      if(contactEmail != null){
        notifyMsg.setFrom(contactEmail);
      }else{
        notifyMsg.setFrom("no-reply@localhost");
      }
    } 
   
    Template fmTemplate1 = null;
    String text1 = null;
    try{     
      fmTemplate1 = freemarkerEngine.getTemplate("login/welcome-template.ftl");     
      text1 = FreeMarkerTemplateUtils.processTemplateIntoString(fmTemplate1,model);
    }catch(Exception e){
      logger.error("ApproveUserAccount: error creating message template from Freemarker engine");
    }
    notifyMsg.setText(text1);
   
    if(getMailSender() == null){
      logger.error("ApproveUserAccount: mailSender bean is not defined");
      addActionError(String.valueOf(ActionErrorCode.ERROR_CONFIG));
      return false;
View Full Code Here

      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;
View Full Code Here

    if(toEmail == null){
      logger.error("RegisterUser: the email of user " + user.getUsername() + " is not defined");
      addActionError(String.valueOf(ActionErrorCode.ERROR_EMAIL_UNDEF));
      return false;
    }
    SimpleMailMessage msg = new SimpleMailMessage(getVerifyEmailTemplate());
    msg.setTo(toEmail);
   
    if(msg.getFrom() == null){
      String contactEmail = getGnizrConfiguration().getSiteContactEmail();
      if(contactEmail != null){
        msg.setFrom(contactEmail);
      }else{
        msg.setFrom("help@localhost");
      }
    }   
       
    Template fmTemplate = null;
    String text = null;
    try{     
      fmTemplate = freemarkerEngine.getTemplate("login/verifyemail-template.ftl");
      text = FreeMarkerTemplateUtils.processTemplateIntoString(fmTemplate,model);
    }catch(Exception e){
      logger.error("RegisterUser: error creating message template from Freemarker engine");
    }

    msg.setText(text);
   
    if(getMailSender() == null){
      logger.error("RegisterUser: mailSender bean is not defined");
      addActionError(String.valueOf(ActionErrorCode.ERROR_CONFIG));
      return false;
View Full Code Here

    if(toEmail == null){
      logger.error("RequestPasswordReset: the email of user " + user.getUsername() + " is not defined");
      addActionError(String.valueOf(ActionErrorCode.ERROR_EMAIL_UNDEF));
      return false;
    }
    SimpleMailMessage msg = new SimpleMailMessage(getVerifyResetTemplate());
    msg.setTo(toEmail);
   
    if(msg.getFrom() == null){
      String contactEmail = getGnizrConfiguration().getSiteContactEmail();
      if(contactEmail != null){
        msg.setFrom(contactEmail);
      }else{
        msg.setFrom("help@localhost");
      }
    }   
       
    Template fmTemplate = null;
    String text = null;
    try{     
      fmTemplate = freemarkerEngine.getTemplate("login/notifyreset-template.ftl");
      text = FreeMarkerTemplateUtils.processTemplateIntoString(fmTemplate,model);
    }catch(Exception e){
      logger.error("RequestPasswordReset: error creating message template from Freemarker engine");
    }

    msg.setText(text);
   
    if(getMailSender() == null){
      logger.error("RequestPasswordReset: mailSender bean is not defined");
      addActionError(String.valueOf(ActionErrorCode.ERROR_CONFIG));
      return false;
View Full Code Here

      List<Object> values = CollectUtils.newArrayList();
      values.add(longinName);
      values.add(password);
      String body = getText("user.password.sendmail.body", values);
      try {
        SimpleMailMessage msg = new SimpleMailMessage(message);
        msg.setTo(user.getMail());
        msg.setSubject(title);
        msg.setText(body.toString());
        mailSender.send(msg);
      } catch (Exception e) {
        e.printStackTrace();
        logger.info("reset password error for user:" + user.getName() + " with email :"
            + user.getMail());
View Full Code Here

        }
        return user;
    }

    private void prepareAndSendNewUserEmail(User user) {
        SimpleMailMessage messageToSend = prepareMailMessage(user);
        sendMessage(messageToSend);
    }
View Full Code Here

    }

    //TODO: MZA: Should be moved to business layer
    private SimpleMailMessage prepareMailMessage(User user) {
        log.debug("Preparing message for user '{}' with an account information", user.getUsername());
        SimpleMailMessage message = new SimpleMailMessage();    //serviceFacade.getMailMessage();
        message.setTo(user.getFullName() + "<" + user.getEmail() + ">");

        StringBuilder msg = new StringBuilder();
        msg.append(getString("signup.email.message"));
        msg.append("\n\n").append(getString("user.username"));
        msg.append(": ").append(user.getUsername()).append("\n");
        msg.append(getString("user.password")).append(": ");
        msg.append(user.getPassword());
        msg.append("\n\nLogin at: ")
                .append(RequestCycle.get().getUrlRenderer().renderFullUrl(
                        Url.parse(urlFor(Login.class, null).toString())));
        message.setText(msg.toString());
        message.setSubject(getString("signup.email.subject"));

        return message;
    }
View Full Code Here

TOP

Related Classes of org.springframework.mail.SimpleMailMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.