Exemplo n.º 1
0
  @Inject
  public SeyrenMailSender(SeyrenConfig seyrenConfig) {

    int port = seyrenConfig.getSmtpPort();
    String host = seyrenConfig.getSmtpHost();
    String username = seyrenConfig.getSmtpUsername();
    String password = seyrenConfig.getSmtpPassword();
    String protocol = seyrenConfig.getSmtpProtocol();

    setPort(port);
    setHost(host);

    Properties props = new Properties();
    if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) {
      props.setProperty("mail.smtp.auth", "true");
      setUsername(username);
      setPassword(password);
    }

    if (getPort() == 587) {
      props.put("mail.smtp.starttls.enable", "true");
    }

    if (props.size() > 0) {
      setJavaMailProperties(props);
    }

    setProtocol(protocol);

    LOGGER.info("{}:{}@{}", username, password, host);
  }
Exemplo n.º 2
0
 @Test
 public void defaultSmtpPortIsCorrect() {
   assertThat(config.getSmtpPort(), is(25));
 }