Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. @Configuration
  2. @PropertySource("classpath:mail.properties")
  3. public class MailingConfig {
  4.  
  5. @Value("${mail.protocol}")
  6. private String mailProtocol;
  7.  
  8. @Value("${mail.smtp.host}")
  9. private String host;
  10.  
  11. @Value("${mail.smtp.port}")
  12. private Integer port;
  13.  
  14. @Value("${mail.support.username}")
  15. private String userName;
  16.  
  17. @Value("${mail.support.password}")
  18. private String password;
  19.  
  20. @Bean
  21. public JavaMailSender javaMailSender() {
  22. JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
  23.  
  24. javaMailSender.setProtocol(mailProtocol);
  25. javaMailSender.setHost(host);
  26. javaMailSender.setPort(port);
  27. javaMailSender.setUsername(userName);
  28. javaMailSender.setPassword(password);
  29.  
  30. javaMailSender.setJavaMailProperties(getMailProperties());
  31.  
  32. return javaMailSender;
  33. }
  34.  
  35. private Properties getMailProperties() {
  36. Properties properties = new Properties();
  37. properties.setProperty("customConfig.smtp.auth", "true");
  38. properties.setProperty("customConfig.smtp.starttls.enable", "true");
  39. properties.setProperty("customConfig.debug", "false");
  40. return properties;
  41. }
  42. }
  43.  
  44. mail.protocol=smtp
  45. mail.smtp.host=*****
  46. mail.smtp.port=25
  47. mail.support.username=****
  48. mail.support.password=****
  49.  
  50. properties.setProperty("customConfig.smtp.auth", "true");
  51. properties.setProperty("customConfig.smtp.starttls.enable", "true");
  52.  
  53. ...
  54.  
  55. mail.support.username=****
  56. mail.support.password=****
  57.  
  58. mail.smtp.host="127.0.0.1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement