@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); }
@Test public void defaultSmtpProtocolIsCorrect() { assertThat(config.getSmtpProtocol(), is("smtp")); }