示例#1
0
  @Override
  public void sendPasswordResetLink(final AppUser user) {
    try {
      if (user.getPasswordResetToken() == null || user.getPasswordResetToken().isEmpty()) {
        return;
      }
      Template template = configuration.getTemplate("resetpassword.ftl");
      final Map model = new HashMap();
      model.put("name", user.getName());
      String password_reset_url = RESET_PASSWORD_URL + "?token=" + user.getPasswordResetToken();
      model.put("password_reset_url", password_reset_url);
      final String mailBody = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
      MimeMessagePreparator preparator =
          new MimeMessagePreparator() {

            public void prepare(MimeMessage mimeMessage) throws Exception {
              MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              message.setTo(user.getEmail());
              message.setSubject("GWA-Portal password reset confirmation");
              message.setFrom(FROM);
              message.setText(mailBody, false);
            }
          };
      mailSender.send(preparator);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
示例#2
0
  @Override
  public void sendPasswordChanged(final AppUser user) {
    try {
      Template template = configuration.getTemplate("passwordchanged.ftl");
      final Map model = new HashMap();
      model.put("name", user.getName());
      final String mailBody = FreeMarkerTemplateUtils.processTemplateIntoString(template, model);
      MimeMessagePreparator preparator =
          new MimeMessagePreparator() {

            public void prepare(MimeMessage mimeMessage) throws Exception {
              MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              message.setTo(user.getEmail());
              message.setSubject("GWA-Portal password changed");
              message.setFrom(FROM);
              message.setText(mailBody, false);
            }
          };
      mailSender.send(preparator);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }