Ejemplo n.º 1
0
 @Bean
 public JavaMailSender mailSender() {
   JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
   mailSender.setDefaultEncoding("UTF-8");
   mailSender.setHost(mailHost);
   mailSender.setPort(new Integer(mailPort));
   return mailSender;
 }
 @Bean
 public JavaMailSender javaMailService() {
   JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
   javaMailSender.setHost(env.getRequiredProperty(PROPERTY_HOST));
   javaMailSender.setPort(parsePortProperty(env.getRequiredProperty(PROPERTY_PORT)));
   javaMailSender.setUsername(env.getRequiredProperty(PROPERTY_USERNAME));
   javaMailSender.setPassword(env.getRequiredProperty(PROPERTY_PASSWORD));
   javaMailSender.setJavaMailProperties(getMailProperties());
   javaMailSender.setDefaultEncoding(WebMvcConfiguration.DEFAULT_CHAR_ENCODING);
   return javaMailSender;
 }
 private void applyProperties(JavaMailSenderImpl sender) {
   sender.setHost(this.properties.getHost());
   if (this.properties.getPort() != null) {
     sender.setPort(this.properties.getPort());
   }
   sender.setUsername(this.properties.getUsername());
   sender.setPassword(this.properties.getPassword());
   sender.setProtocol(this.properties.getProtocol());
   if (this.properties.getDefaultEncoding() != null) {
     sender.setDefaultEncoding(this.properties.getDefaultEncoding().name());
   }
   if (!this.properties.getProperties().isEmpty()) {
     sender.setJavaMailProperties(asProperties(this.properties.getProperties()));
   }
 }
Ejemplo n.º 4
0
 private void organMailContent() {
   mailSender.setHost(ConfigManager.getInstance().getString("mail.host"));
   mailSender.setPort(ConfigManager.getInstance().getInt("mail.port", 25));
   mailSender.setUsername(ConfigManager.getInstance().getString("mail.username"));
   mailSender.setPassword(ConfigManager.getInstance().getString("mail.password"));
   mailSender.setDefaultEncoding("utf-8");
   log.info(
       "HOST>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>mailSender.getHost()="
           + mailSender.getHost()
           + ",mailSender.getPort()="
           + mailSender.getPort());
   Properties props = new Properties();
   props.setProperty("mail.smtp.auth", "true");
   props.setProperty("mail.smtp.timeout", "0");
   mailSender.setJavaMailProperties(props);
   this.setMailSender(mailSender);
 }
Ejemplo n.º 5
0
  public void updateJavaMailSender() {
    javaMailSender = new JavaMailSenderImpl();

    javaMailSender.setHost(host);

    if (smtpAuth) {
      javaMailSender.setUsername(username);
      javaMailSender.setPassword(password);
    }

    javaMailSender.setDefaultEncoding("UTF-8");

    javaMailSender.setJavaMailProperties(this.getProperties());
    logger.info("host : {}", host);
    logger.info("username : {}", username);
    logger.info("password : {}", password);
    logger.info("getProperties : {}", getProperties());
  }