use of org.springframework.mail.javamail.JavaMailSenderImpl in project oc-explorer by devgateway.
the class EmailServiceConfiguration method javaMailSenderImpl.
@Bean
public JavaMailSenderImpl javaMailSenderImpl() {
JavaMailSenderImpl jmsi = new JavaMailSenderImpl();
jmsi.setHost("localhost");
jmsi.setPort(SMTP_PORT);
return jmsi;
}
use of org.springframework.mail.javamail.JavaMailSenderImpl in project alf.io by alfio-event.
the class SmtpMailer method toMailSender.
private static JavaMailSender toMailSender(Map<ConfigurationKeys, ConfigurationManager.MaybeConfiguration> conf) {
JavaMailSenderImpl r = new CustomJavaMailSenderImpl();
r.setDefaultEncoding("UTF-8");
r.setHost(conf.get(SMTP_HOST).getRequiredValue());
r.setPort(Integer.parseInt(conf.get(SMTP_PORT).getRequiredValue()));
r.setProtocol(conf.get(SMTP_PROTOCOL).getRequiredValue());
r.setUsername(conf.get(SMTP_USERNAME).getValueOrNull());
r.setPassword(conf.get(SMTP_PASSWORD).getValueOrNull());
String properties = conf.get(SMTP_PROPERTIES).getValueOrNull();
if (properties != null) {
try {
Properties prop = PropertiesLoaderUtils.loadProperties(new EncodedResource(new ByteArrayResource(properties.getBytes(StandardCharsets.UTF_8)), "UTF-8"));
r.setJavaMailProperties(prop);
} catch (IOException e) {
log.warn("error while setting the mail sender properties", e);
}
}
return r;
}
Aggregations