use of org.springframework.mail.javamail.JavaMailSenderImpl in project goci by EBISPOT.
the class GOCIMailConfiguration method javaMailSender.
// @Emma Code based on: http://stackoverflow.com/questions/22483407/send-emails-with-spring-by-using-java-annotations
@Bean
public JavaMailSender javaMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setJavaMailProperties(getMailProperties());
mailSender.setHost(host);
mailSender.setPort(port);
mailSender.setProtocol(protocol);
return mailSender;
}
use of org.springframework.mail.javamail.JavaMailSenderImpl in project spring-boot by spring-projects.
the class MailSenderAutoConfigurationTests method smtpHostWithSettings.
@Test
void smtpHostWithSettings() {
String host = "192.168.1.234";
this.contextRunner.withPropertyValues("spring.mail.host:" + host, "spring.mail.port:42", "spring.mail.username:john", "spring.mail.password:secret", "spring.mail.default-encoding:US-ASCII", "spring.mail.protocol:smtps").run((context) -> {
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThat(mailSender.getHost()).isEqualTo(host);
assertThat(mailSender.getPort()).isEqualTo(42);
assertThat(mailSender.getUsername()).isEqualTo("john");
assertThat(mailSender.getPassword()).isEqualTo("secret");
assertThat(mailSender.getDefaultEncoding()).isEqualTo("US-ASCII");
assertThat(mailSender.getProtocol()).isEqualTo("smtps");
});
}
use of org.springframework.mail.javamail.JavaMailSenderImpl in project spring-boot by spring-projects.
the class MailSenderAutoConfigurationTests method connectionOnStartup.
@Test
void connectionOnStartup() {
this.contextRunner.withUserConfiguration(MockMailConfiguration.class).withPropertyValues("spring.mail.host:10.0.0.23", "spring.mail.test-connection:true").run((context) -> {
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
then(mailSender).should().testConnection();
});
}
use of org.springframework.mail.javamail.JavaMailSenderImpl in project spring-boot by spring-projects.
the class MailSenderAutoConfigurationTests method mailSenderBackOff.
@Test
void mailSenderBackOff() {
this.contextRunner.withUserConfiguration(ManualMailConfiguration.class).withPropertyValues("spring.mail.host:smtp.acme.org", "spring.mail.user:user", "spring.mail.password:secret").run((context) -> {
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThat(mailSender.getUsername()).isNull();
assertThat(mailSender.getPassword()).isNull();
});
}
use of org.springframework.mail.javamail.JavaMailSenderImpl in project spring-boot by spring-projects.
the class MailSenderAutoConfigurationTests method smtpHostSet.
@Test
void smtpHostSet() {
String host = "192.168.1.234";
this.contextRunner.withPropertyValues("spring.mail.host:" + host).run((context) -> {
assertThat(context).hasSingleBean(JavaMailSenderImpl.class);
JavaMailSenderImpl mailSender = context.getBean(JavaMailSenderImpl.class);
assertThat(mailSender.getHost()).isEqualTo(host);
assertThat(mailSender.getPort()).isEqualTo(JavaMailSenderImpl.DEFAULT_PORT);
assertThat(mailSender.getProtocol()).isEqualTo(JavaMailSenderImpl.DEFAULT_PROTOCOL);
});
}
Aggregations