package be.mentoringsystems.merke.config; import java.util.Properties; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.mail.javamail.JavaMailSender; import org.springframework.mail.javamail.JavaMailSenderImpl; /** * * @author anthonyarents */ @Configuration public class MailConfiguration { @Value("#{contextParameters.email_host}") private String host; @Value("#{contextParameters.email_user}") private String user; @Value("#{contextParameters.email_pass}") private String pass; @Value("#{contextParameters.email_port}") private Integer port; @Value("#{contextParameters.email_auth}") private Boolean auth; @Value("#{contextParameters.email_starttls}") private Boolean starttls; @Bean(name = "javaMailService") public JavaMailSender javaMailService() { JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); javaMailSender.setDefaultEncoding("UTF-8"); javaMailSender.setHost(host); javaMailSender.setUsername(user); javaMailSender.setPassword(pass); javaMailSender.setPort(port); final Properties properties = new Properties(); properties.setProperty("mail.smtp.auth", Boolean.toString(auth)); properties.setProperty("mail.smtp.starttls.enable", Boolean.toString(starttls)); javaMailSender.setJavaMailProperties(properties); return javaMailSender; } }