[GH-ISSUE #235] Responses with different SMTP error codes #153

Closed
opened 2026-03-15 12:52:55 +03:00 by kerem · 4 comments
Owner

Originally created by @DragoMlakar on GitHub (Jan 15, 2024).
Original GitHub issue: https://github.com/axllent/mailpit/issues/235

It would be convenient for testing that on some conditions response is SMTP error code.
Maybe some list of email addresses and error codes. Or even on mail content parsing.
Can this be done already and I'm missing something?

Originally created by @DragoMlakar on GitHub (Jan 15, 2024). Original GitHub issue: https://github.com/axllent/mailpit/issues/235 It would be convenient for testing that on some conditions response is SMTP error code. Maybe some list of email addresses and error codes. Or even on mail content parsing. Can this be done already and I'm missing something?
kerem closed this issue 2026-03-15 12:53:01 +03:00
Author
Owner

@axllent commented on GitHub (Jan 15, 2024):

@DragoMlakar There is currently no way to artificially return an SMTP error code, only if there is an actual error. You could for instance set the --smtp-max-recipients 3 and provide 4 addresses (which would return an error code).

What exactly are you trying to test here?

<!-- gh-comment-id:1892802051 --> @axllent commented on GitHub (Jan 15, 2024): @DragoMlakar There is currently no way to artificially return an SMTP error code, only if there is an actual error. You could for instance set the `--smtp-max-recipients 3` and provide 4 addresses (which would return an error code). What exactly are you trying to test here?
Author
Owner

@DragoMlakar commented on GitHub (Jan 16, 2024):

Testing how real postfix behave on SMTP errors. Currently if all different NDN bounce mails are DKIM signed. It would be also convenient to test application logic how it handles different SMTP responses.

<!-- gh-comment-id:1893300626 --> @DragoMlakar commented on GitHub (Jan 16, 2024): Testing how real postfix behave on SMTP errors. Currently if all different NDN bounce mails are DKIM signed. It would be also convenient to test application logic how it handles different SMTP responses.
Author
Owner

@axllent commented on GitHub (Jan 16, 2024):

Unfortunately what you are describing is completely out of scope for Mailpit - can you imagine how much work it would be to implement a full postfix "clone" including Non Delivery Reports, DKIM etc? The whole idea of Mailpit it that it accepts everything (provided it is a valid message + SMTP transaction), and then allows you to see what was delivered. Simply put, Mailpit is not postfix.

I have also considered artificial SMTP errors, but this gets really complicated to do it properly. I've seen some solutions that just return random error responses, however it is important that these errors are returned at the correct stage during the SMTP transaction, and again gets very complicated to implement correctly, especially when different SMTP servers return very different error messages for the same things.

You may find your solution by delivering your emails directly to an actual postfix server which is then configured to relay messages to Mailpit, but that's about all I can suggest, sorry.

<!-- gh-comment-id:1893364745 --> @axllent commented on GitHub (Jan 16, 2024): Unfortunately what you are describing is completely out of scope for Mailpit - can you imagine how much work it would be to implement a full postfix "clone" including Non Delivery Reports, DKIM etc? The whole idea of Mailpit it that it accepts everything (provided it is a valid message + SMTP transaction), and then allows you to see what was delivered. Simply put, Mailpit is not postfix. I have also considered artificial SMTP errors, but this gets really complicated to do it properly. I've seen some solutions that just return random error responses, however it is important that these errors are returned at the correct stage during the SMTP transaction, and again gets very complicated to implement correctly, especially when different SMTP servers return very different error messages for the same things. You may find your solution by delivering your emails directly to an actual postfix server which is then configured to relay messages to Mailpit, but that's about all I can suggest, sorry.
Author
Owner

@DragoMlakar commented on GitHub (Jan 16, 2024):

Thnx for feedback.
Found one that looks promising.
https://medium.com/linagora-engineering/a-mock-smtp-server-for-remote-mail-delivery-testing-2d1a2cfd2798

<!-- gh-comment-id:1893510859 --> @DragoMlakar commented on GitHub (Jan 16, 2024): Thnx for feedback. Found one that looks promising. https://medium.com/linagora-engineering/a-mock-smtp-server-for-remote-mail-delivery-testing-2d1a2cfd2798
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#153
No description provided.