Files
spring-boot-demo/email/output/06-failure-modes.txt
T
Claude da700a564f Add email module: JavaMailSender on Spring Boot 4.1.2 / Jakarta Mail 2.1.5, tested against GreenMail with real transcripts
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
2026-11-18 21:17:37 +05:30

28 lines
1.6 KiB
Plaintext

== wrong password
org.springframework.mail.MailAuthenticationException: Authentication failed
jakarta.mail.AuthenticationFailedException: 535 5.7.8 Authentication credentials invalid
== right password
delivered: 1 message
== nothing listening on the port
org.springframework.mail.MailSendException
org.springframework.mail.MailSendException: Mail server connection failed. Failed messages: org.eclipse.angus.mail.util.MailConnectException: Couldn't connect to host, port: 127.0.0.1, 32877; timeout -1;
org.eclipse.angus.mail.util.MailConnectException: Couldn't connect to host, port: 127.0.0.1, 32877; timeout -1
java.net.ConnectException: Connection refused
== recipient that is not an address: 'not an address'
org.springframework.mail.MailParseException
org.springframework.mail.MailParseException: Could not parse mail
jakarta.mail.internet.AddressException: Local address contains control or whitespace
== server accepts the TCP connection and never sends the SMTP greeting
no timeouts set -> still blocked after 3000 ms; the caller is stuck
(after the connection was dropped: MailSendException)
mail.smtp.connectiontimeout=500 -> still blocked after 3000 ms; the caller is stuck
(after the connection was dropped: MailSendException)
mail.smtp.timeout=500 -> failed after ~500 ms
org.springframework.mail.MailSendException: Mail server connection failed. Failed messages: jakarta.mail.MessagingException: Exception reading response;
jakarta.mail.MessagingException: Exception reading response
java.net.SocketTimeoutException: Read timed out