[GH-ISSUE #455] Spring Boot / JavaMail cannot send mails? #293

Closed
opened 2026-03-15 13:45:03 +03:00 by kerem · 3 comments
Owner

Originally created by @twiedow on GitHub (Mar 3, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/455

I'm currently trying to send emails to mailpit from my Spring Boot app. Internally it uses JavaMail. It seems that it cannot connect to the mailpit SMPT server.

Is there any known issue with Spring Boot or JavaMail using together with mailpit? Sending mails via command line is working and I see log messages about it. But when trying to connect from Spring Boot there are no log messages at all, also in verbose mode.

These are the Spring Boot properties:

spring.mail.host=localhost
spring.mail.port=1025
spring.mail.properties.mail.debug=true

This I get in the Java stack trace:

DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "localhost", port 1025, isSSL false
DEBUG SMTP: EOF: [EOF]
DEBUG SMTP: got bad greeting from host "localhost", port: 1025, response: [EOF]

Mail server connection failed. Failed messages: jakarta.mail.MessagingException: Got bad greeting from SMTP host: localhost, port: 1025, response: [EOF]
org.springframework.mail.MailSendException: Mail server connection failed. Failed messages: jakarta.mail.MessagingException: Got bad greeting from SMTP host: localhost, port: 1025, response: [EOF]; message exception details (1) are:
Failed message 1:
jakarta.mail.MessagingException: Got bad greeting from SMTP host: localhost, port: 1025, response: [EOF]
Originally created by @twiedow on GitHub (Mar 3, 2025). Original GitHub issue: https://github.com/axllent/mailpit/issues/455 I'm currently trying to send emails to mailpit from my Spring Boot app. Internally it uses JavaMail. It seems that it cannot connect to the mailpit SMPT server. Is there any known issue with Spring Boot or JavaMail using together with mailpit? Sending mails via command line is working and I see log messages about it. But when trying to connect from Spring Boot there are no log messages at all, also in verbose mode. These are the Spring Boot properties: ``` spring.mail.host=localhost spring.mail.port=1025 spring.mail.properties.mail.debug=true ``` This I get in the Java stack trace: ``` DEBUG SMTP: useEhlo true, useAuth false DEBUG SMTP: trying to connect to host "localhost", port 1025, isSSL false DEBUG SMTP: EOF: [EOF] DEBUG SMTP: got bad greeting from host "localhost", port: 1025, response: [EOF] Mail server connection failed. Failed messages: jakarta.mail.MessagingException: Got bad greeting from SMTP host: localhost, port: 1025, response: [EOF] org.springframework.mail.MailSendException: Mail server connection failed. Failed messages: jakarta.mail.MessagingException: Got bad greeting from SMTP host: localhost, port: 1025, response: [EOF]; message exception details (1) are: Failed message 1: jakarta.mail.MessagingException: Got bad greeting from SMTP host: localhost, port: 1025, response: [EOF] ```
kerem closed this issue 2026-03-15 13:45:08 +03:00
Author
Owner

@axllent commented on GitHub (Mar 3, 2025):

I am not aware of any issues, however I have no experience with Spring Boot / JavaMail.

Have you tried running Mailpit in verbose mode to see if the client is even connecting?

<!-- gh-comment-id:2694282320 --> @axllent commented on GitHub (Mar 3, 2025): I am not aware of any issues, however I have no experience with Spring Boot / JavaMail. Have you tried running Mailpit in verbose mode to see if the client is even connecting?
Author
Owner

@twiedow commented on GitHub (Mar 3, 2025):

Yes, I tried in verbose mode. Unfortunately nothing is logged at all, but I guess the problem lies in the JavaMail client and the way it creates a socket connection to the SMPT server.
I hoped that you might know which properties I might have to set to get the JavaMail client running.

Thanks anyway and thanks for this great project.

<!-- gh-comment-id:2694497183 --> @twiedow commented on GitHub (Mar 3, 2025): Yes, I tried in verbose mode. Unfortunately nothing is logged at all, but I guess the problem lies in the JavaMail client and the way it creates a socket connection to the SMPT server. I hoped that you might know which properties I might have to set to get the JavaMail client running. Thanks anyway and thanks for this great project.
Author
Owner

@axllent commented on GitHub (Mar 3, 2025):

I googled "Spring Boot and Mailpit" and I can see several articles of how to set it up, so it definitely does work. I strongly suspect it's a configuration issue on your Spring Boot end. It would be great if you could leave a comment here (once you have found the solution) for reference. I'll close this issue as it's not a Mailpit issue. Thanks.

<!-- gh-comment-id:2695172954 --> @axllent commented on GitHub (Mar 3, 2025): I googled "Spring Boot and Mailpit" and I can see several articles of how to set it up, so it definitely does work. I strongly suspect it's a configuration issue on your Spring Boot end. It would be great if you could leave a comment here (once you have found the solution) for reference. I'll close this issue as it's not a Mailpit issue. Thanks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#293
No description provided.