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()); }