Question

I'm looking for a mail server mock that can be configured like a Mockito mock object. Currently we are using GreenMail as mail server mock, but I would like to do something like this in my unit tests:

  • if mail with subject xyz arrives, accept.
  • if mail with subject zz1 arrives, send temporarily failure
  • if mail with subject fh2 arrives, send bounce (unknown recipient).
  • .....

As I can see, GreenMail is not capable of this. Does anyone knows a library which can do something like this?

Was it helpful?

Solution

So, finally i extended greenmail with the functionallity to close smtp server after x mails or skip acceptance of smtp connection after x mails and to slow down the smtp handling for a specific mail. Thanks for the answers. Its possible that i'm allowed to push my changes back to greenmail trunk. We'll see.

OTHER TIPS

I've used "dumbster" (http://quintanasoft.com/dumbster/) in the past and it's worked well. I just checked the javadoc and I don't see any configurable ability to accept/reject messages based on arbitrary criteria, but it is open source so it might be straightforward to add this capability.

Someone I know use this succesfully in his codebase. It's basically updated link from Usman Saleem's comment on the question above.

https://github.com/voodoodyne/subethasmtp/blob/master/Wiser.md

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top