mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 00:35:51 +03:00
[GH-ISSUE #517] SMTP Relay Timeout Blocks Client Connection Until External Timeout #333
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#333
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Lunaden on GitHub (Jun 12, 2025).
Original GitHub issue: https://github.com/axllent/mailpit/issues/517
Description
We are using Mailpit as an SMTP relay in a test environment, configured via Docker:
The service works well in most cases. However, we have noticed that when Mailpit attempts to relay to certain external SMTP servers (e.g.,
mail.example.com:25), it sometimes encounters connection timeouts, and during this time the client that initiated the email remains blocked until the timeout occurs.Here are sample logs showing the issue:
Expected Behavior
Mailpit should accept the message from the SMTP client and respond immediately, even if the relay target is unreachable, handling the external delivery asynchronously.
Actual Behavior
When the relay fails (e.g., connection timeout), the SMTP client is kept waiting until the timeout completes. This causes blocking behavior in our upstream systems.
Context
This behavior is observed in a test environment, so the impact is currently limited. However, it is still disruptive during development, testing, and performance benchmarking, and would be problematic in a production setup.
Questions
Environment
axllent/mailpit@axllent commented on GitHub (Jun 12, 2025):
Hi @Lunaden. I'll try respond to your questions, but please forgive me if I try keep this as short as I can as I need to get to bed.
The first thing to note is that Mailpit is a development tool, not a production tool, it's written everywhere in the title, descriptions etc. The relay functionality was added as an afterthought (feature request) which was manually initiated (releasing mail via the web UI), and later with an option to automatically relay all messages. This was however never intended to work as a high load transparent proxy which appears to be how you are using it.
I would also never recommend benchmarking delivery while Mailpit is connected to a third party SMTP server as that will be a sure way to get yourself banned.
It is 100% synchronous by design, and there is no option to change this because that functionality does not exist. The reasoning for this is if Mailpit was do what you are asking (to queue messages and send them in the background), then it would need to also handle all the other features of an actual mail server (like postfix), including rate limited sending, temporary deferrals, retries, bounces etc. That is not the purpose of Mailpit, that is the purpose of an actual mail server which is designed to send emails. Mailpit is designed to receive emails, not to send them. Trying to replicate that within Mailpit would be a huge amount of work to do properly - basically to build a complete mail server, and this is completely out of scope of this project.
For the reasons I provided above, unfortunately no. There is a solution to your problem however, you need to set up an actual mail server (eg: postfix) as a relay proxy between Mailpit and your third party, which can then handle the sending, delays, etc. This way Mailpit can relay a tonne of emails to postfix (without delays) and let it handle the sending part, regardless how long those third party SMTP servers.
I hope this answers your questions?
@Lunaden commented on GitHub (Jun 12, 2025):
Hi, thank you very much for your detailed reply despite the late hour — much appreciated.
Just to clarify:
Thank you again for your time and clear guidance !