From d8bf3a72da1e9bf4c69b4244242517916f246d1b Mon Sep 17 00:00:00 2001 From: jhernan Date: Mon, 3 Aug 2015 15:32:43 +0200 Subject: [PATCH] Customize mail sender protocol See gh-3649 --- .../boot/autoconfigure/mail/MailProperties.java | 13 +++++++++++++ .../mail/MailSenderAutoConfiguration.java | 3 +++ 2 files changed, 16 insertions(+) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java index bd2b54146c..2b7549454f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java @@ -55,6 +55,11 @@ public class MailProperties { */ private String password; + /** + * Protocol used by the SMTP server. + */ + private String protocol; + /** * Default MimeMessage encoding. */ @@ -107,6 +112,14 @@ public class MailProperties { this.password = password; } + public String getProtocol() { + return this.protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + public Charset getDefaultEncoding() { return this.defaultEncoding; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java index 37a0938916..7795526906 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java @@ -79,6 +79,9 @@ public class MailSenderAutoConfiguration { } sender.setUsername(this.properties.getUsername()); sender.setPassword(this.properties.getPassword()); + if (this.properties.getProtocol() != null) { + sender.setProtocol(this.properties.getProtocol()); + } if (this.properties.getDefaultEncoding() != null) { sender.setDefaultEncoding(this.properties.getDefaultEncoding().name()); }