Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Configuration
- @PropertySource("classpath:mail.properties")
- public class MailingConfig {
- @Value("${mail.protocol}")
- private String mailProtocol;
- @Value("${mail.smtp.host}")
- private String host;
- @Value("${mail.smtp.port}")
- private Integer port;
- @Value("${mail.support.username}")
- private String userName;
- @Value("${mail.support.password}")
- private String password;
- @Bean
- public JavaMailSender javaMailSender() {
- JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
- javaMailSender.setProtocol(mailProtocol);
- javaMailSender.setHost(host);
- javaMailSender.setPort(port);
- javaMailSender.setUsername(userName);
- javaMailSender.setPassword(password);
- javaMailSender.setJavaMailProperties(getMailProperties());
- return javaMailSender;
- }
- private Properties getMailProperties() {
- Properties properties = new Properties();
- properties.setProperty("customConfig.smtp.auth", "true");
- properties.setProperty("customConfig.smtp.starttls.enable", "true");
- properties.setProperty("customConfig.debug", "false");
- return properties;
- }
- }
- mail.protocol=smtp
- mail.smtp.host=*****
- mail.smtp.port=25
- mail.support.username=****
- mail.support.password=****
- properties.setProperty("customConfig.smtp.auth", "true");
- properties.setProperty("customConfig.smtp.starttls.enable", "true");
- ...
- mail.support.username=****
- mail.support.password=****
- mail.smtp.host="127.0.0.1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement