Advertisement
Guest User

Untitled

a guest
Mar 13th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. @Configuration
  2. @PropertySource("file:///${CONFIG_LOCATION}/smtp_config.properties")
  3. @ConfigurationProperties(prefix = "mail")
  4. public class SmtpProducerBase {
  5. private String host;
  6. private String port;
  7. private String password;
  8. private String mail;
  9. private boolean smtpStarttls;
  10. private boolean smtpAuth;
  11.  
  12. public String getHost() {
  13. return host;
  14. }
  15. public void setHost(String host) {
  16. this.host = host;
  17. }
  18. public String getPort() {
  19. return port;
  20. }
  21. public void setPort(String port) {
  22. this.port = port;
  23. }
  24. public String getPassword() {
  25. return password;
  26. }
  27. public void setPassword(String password) {
  28. this.password = password;
  29. }
  30. public String getMail() {
  31. return mail;
  32. }
  33. public void setMail(String mail) {
  34. this.mail = mail;
  35. }
  36. public boolean isSmtpStarttls() {
  37. return smtpStarttls;
  38. }
  39. public void setSmtpStarttls(boolean smtpStarttls) {
  40. this.smtpStarttls = smtpStarttls;
  41. }
  42. public boolean isSmtpAuth() {
  43. return smtpAuth;
  44. }
  45. public void setSmtpAuth(boolean smtpAuth) {
  46. this.smtpAuth = smtpAuth;
  47. }
  48. }
  49.  
  50. @Component
  51. public class SMTPProducerRouteBase extends ConfigurationRoute {
  52. @Autowired
  53. private SmtpProducerBase smtpProducerBase;
  54.  
  55. public void configure() throws Exception {
  56. super.configure();
  57. from("direct:sendMail").id("send_mail_route")
  58. .log("Enviando mensaje...")
  59. .to("smtp://sendMail?"
  60. + "host="+smtpProducerBase.getHost()
  61. + "&port="+smtpProducerBase.getPort()
  62. + "&contentType=text/html"
  63. + "&password="+smtpProducerBase.getPassword()
  64. + "&username="+smtpProducerBase.getMail()
  65. + "&mail.smtp.starttls.enable="+smtpProducerBase.isSmtpStarttls()
  66. + "&mail.smtp.auth="+smtpProducerBase.isSmtpAuth())
  67. .log("Proceso de envío finalizado.")
  68. .end();
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement