Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing SMTP Server Error Responses #402

Open
IBlasterus opened this issue Dec 9, 2024 · 4 comments · May be fixed by #405
Open

Testing SMTP Server Error Responses #402

IBlasterus opened this issue Dec 9, 2024 · 4 comments · May be fixed by #405
Labels
enhancement New feature or request

Comments

@IBlasterus
Copy link

Sometimes during development you need to write logic for error responses from the SMTP server.
Can you add this feature to Mailpit Test Server?
There could be some startup keys that make Mailpit respond with an error.
For example, 451.

@axllent
Copy link
Owner

axllent commented Dec 9, 2024

Previously a "chaos monkey" feature was requested (see #110, #144 & #268) to return SMTP errors at random. That proposal was rejected at the time because it was impossible to implement (properly) due to the fact that Mailpit was reliant a third party library for SMTP. Whilst Mailpit is still using a version of that library, it is now within the Mailpit codebase meaning it is now technically possible.

What you are asking for however is something different, so to help me understand your requirements:

  1. Are you wanting a 100% chance of failure in your tests, or at random?
  2. Is there a specific type of failure in the SMTP transaction, or is any SMTP error OK?
  3. Should the error result in a SMTP server disconnection, or...?
  4. Anything else you can think of...

The example given previously was MailHog's Jim feature which is what many/all of these previous requests were based on, and which may help provide some suggestions and ideas for this discussion.

Just to be clear, I'm not saying (yet) whether I will add this option, I'm just a lot more open to it now because it is now possible, it just needs to be implemented properly which takes a solid understanding of the requirements, and of course planning. It is also worth mentioning that I am having shoulder surgery in 2 days, so if I am to add this option it would likely only be in January or February next year, which gives me plenty of time to consider the options before then.

@IBlasterus
Copy link
Author

Thank you very much for taking the time to answer my question.
I wish you a speedy recovery.

  1. Are you wanting a 100% chance of failure in your tests, or at random?

Especially for me need 100% chance of failure.

  1. Is there a specific type of failure in the SMTP transaction, or is any SMTP error OK?

Need specific type of failure. For example, for development backend reaction on 451 error.

  1. Should the error result in a SMTP server disconnection, or...?

Maybe. My Backend connect to SMTP, send E-mail and disconnect.

  1. Anything else you can think of...

Nothing else comes to mind.

@axllent axllent added the enhancement New feature or request label Dec 10, 2024
@ThomasLandauer
Copy link
Contributor

Just an idea on how to implement this:
Hard-code an email address like [email protected], and if it's used as sender/receiver, return that error.
Any more fancy way (like sending some special keywords in the SMTP session) won't work, since most users probably can't modify that.

@axllent
Copy link
Owner

axllent commented Dec 11, 2024

Now that's an interesting approach, thanks for the idea @ThomasLandauer 👍

Edit: After some thought and as nice as this idea sounds, it is very limited in that the email would need to have already been processed in order to process the addresses, meaning the only failure one could trigger this way would be after a successful transaction.

ThomasLandauer added a commit to ThomasLandauer/mailpit that referenced this issue Dec 12, 2024
Closes axllent#402

My knowledge of Go is (in your syntax): `nil`
But I'm sure you get the idea :-)

Based on your comment at axllent#402 (comment)
> the email would need to have already been processed in order to process the addresses

I'm *guessing* that maybe you aren't using the address given at `MAIL FROM` at all. If this is indeed the case, then it certainly would be easy to capture the contents of your `mailFromRE`s first parentheses into some variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants