Clarify scope of JNDI-based MailSenderAutoConfiguration

This commit separates the auto-configuration of JavaMailSender in two
distinct configuration: one based on existing Session available on JNDI
and the other one based on properties configuration.

This clarifies the auto-configuration report and the fact that the JNDI
variant overrides any Session-related properties that would have been
set in the environment

Closes gh-13026
This commit is contained in:
Stephane Nicoll
2018-05-31 16:18:45 +02:00
parent bb0550ab95
commit f745f20c8c
7 changed files with 140 additions and 66 deletions

View File

@@ -96,10 +96,10 @@ content into your application; rather pick only the properties that you need.
# Email ({sc-spring-boot-autoconfigure}/mail/MailProperties.{sc-ext}[MailProperties])
spring.mail.default-encoding=UTF-8 # Default MimeMessage encoding.
spring.mail.host= # SMTP server host. For instance `smtp.example.com`
spring.mail.jndi-name= # Session JNDI name. When set, takes precedence to others mail settings.
spring.mail.jndi-name= # Session JNDI name. When set, takes precedence to others Session settings.
spring.mail.password= # Login password of the SMTP server.
spring.mail.port= # SMTP server port.
spring.mail.properties.*= # Additional JavaMail session properties.
spring.mail.properties.*= # Additional JavaMail Session properties.
spring.mail.protocol=smtp # Protocol used by the SMTP server.
spring.mail.test-connection=false # Test that the mail server is available on startup.
spring.mail.username= # Login user of the SMTP server.

View File

@@ -5046,6 +5046,15 @@ to avoid having a thread blocked by an unresponsive mail server:
spring.mail.properties.mail.smtp.writetimeout=5000
----
It is also possible to configure a `JavaMailSender` with an existing `Session` from JNDI:
[source,properties,indent=0]
----
spring.mail.jndi-name=mail/Session
----
When a `jndi-name` is set, it takes precedence over all other Session-related settings.
[[boot-features-jta]]