Nine tests, each writing a transcript to email/output/: the MIME tree for six message shapes (mixed > related > alternative; addInline before setText puts the image first; addAttachment on a non-multipart helper throws), Thymeleaf HTML and TEXT templates ([[...]] still HTML-escapes in TEXT mode, [(...)] does not), Devanagari subjects as encoded-words and a wrong defaultEncoding turning them into '?', connections and latency through a delaying TCP proxy (5 connections for one send per message, 1 for the varargs send, @Async returning in milliseconds), a void @Async failure that never reaches the caller, a server that never sends the SMTP greeting blocking forever until mail.smtp.timeout is set (connectiontimeout does not help), starttls.enable authenticating over plain text with the base64 password captured on the wire while starttls.required refuses, spring.mail.* mapped onto JavaMailSenderImpl, spring.mail.test-connection, and an email still sent when the transaction rolls back unless it waits for AFTER_COMMIT. Found while writing: GreenMailExtension starts per test method by default, so a @DynamicPropertySource that reads its port needs withPerMethodLifecycle(false). No docs/ folder; the explanations live in the article's accordions. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7SK2mvUEELeLtMi1o
20 lines
1.4 KiB
Plaintext
20 lines
1.4 KiB
Plaintext
== spring.mail.host, port, username, default-encoding, ssl.enabled and two mail.* properties
|
|
bean : JavaMailSenderImpl
|
|
host / port : smtp.example.test / 2525
|
|
protocol : smtp
|
|
defaultEncoding : UTF-8
|
|
session props : {mail.smtp.auth=true, mail.smtp.ssl.checkserveridentity=true, mail.smtp.ssl.enable=true, mail.smtp.timeout=7000}
|
|
|
|
== no spring.mail.host
|
|
JavaMailSender bean present: false
|
|
|
|
== no spring.mail.host, and a bean that needs a JavaMailSender
|
|
No qualifying bean of type 'org.springframework.mail.javamail.JavaMailSender' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
|
|
|
|
== spring.mail.test-connection=true against a port nothing listens on
|
|
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.mail.autoconfigure.MailSenderValidatorAutoConfiguration': Failed to instantiate [org.springframework.boot.mail.autoconfigure.MailSenderValidatorAutoConfiguration]: Constructor threw exception
|
|
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.mail.autoconfigure.MailSenderValidatorAutoConfiguration]: Constructor threw exception
|
|
java.lang.IllegalStateException: Mail server is not available
|
|
org.eclipse.angus.mail.util.MailConnectException: Couldn't connect to host, port: 127.0.0.1, 1; timeout -1
|
|
java.net.ConnectException: Connection refused
|