5 ms·
Not trolling, but why would any developer need a service like this? Isn't that what Mocking frameworks and Interfaces (Interface driven design) are for? Ex: I
by justboxing 9y ago
Not trolling, but why would any developer need a service like this? Isn't that what Mocking frameworks and Interfaces (Interface driven design) are for?
Ex: I would create an interface called IMailService with the operations like Send etc, and once my application is ready, just swap the concrete implementation of the MailService class with the one that talks to the real mail service using Dependency Injection.
If it's not for developers, who would use something like this?
- stingraycharles 9y agoSometimes you want to do a higher level integration / end to end test. Consider for example where you’re testing a docker image and need to provide an SMTP endpoint. This could be a solution.
- amigoingtodie 9y agoSo, I have an application that sends alerts via email and 'sms', and to save costs for some sms messages, I use the cell provider's email address w/ the user's phone number. These alerts can go to a user and/or a user's supervisor(s). Additionally, the content of the message is dynamic. This service would be very easy to add as a config option and let non-technical coworkers test the application for accuracy. Also, I will know that SMTP is actually working. Otherwise, I need to write the code and a UI for the non-technical coworker, and a way to store it. I have other things I need to work on.
- brazzledazzle 9y agoNot sure what you're alerting for so maybe it doesn't matter but I just wanted to warn you about using sms mail gateways. Most of the time the email gateways work (with varying delays) but I've seen every major provider fail or take days to deliver when I needed it the most.
- amigoingtodie 9y agoI know. We use Twilio for the 'important' alerts and the gateways for 'nice to have'. But, as you said, it can be iffy, so that is why I want to know if the issue is with stuff I control, or them. So, at least I know it is being sent and my logic is solid.
- brazzledazzle 9y agoThat’s a smart way to do it.
- amigoingtodie 9y agoThanks.
- eesmith 9y agoHow do you test your mocks to ensure they match real SMTP/IMAP/POP client behavior? If the same developers write the clients and the mocks, then it's likely that both components implement identical misunderstandings, if there are misunderstandings.
- a-nikolaev 9y agoYou can run your program with a testing set of users, where all potential receivers of your mock messages are your own emails. Is it not enough?
- eesmith 9y agoIt's what I do. However, I rarely integrate with email, and when I do it's for in-house email addresses. That said, I was giving an example of why a mock might not be an appropriate solution, and not on the wider topic of what "enough" might be. I can certainly think that testing the ability to send emails to, say, 5,000 different addresses, and check that they are received, might be easier with something like this system.
- nathancahill 9y agoRelevant story from my friends at Fetchnotes: https://web.archive.org/web/20161114132954/http://blog.fetchnotes.com/post/17155558880/what-happens-when-you-swear-at-your-users https://web.archive.org/web/20161114132954/http://blog.fetch...
- itake 9y agoWe use mailcatcher[0] on our sandbox server so that product and QA can test email features in a live environment. Mailcatcher was a drop in replacement with our existing codebase. No need to add in additional business logic specific for testing or have to write our own interface to expose the "sent" emails. [0] https://mailcatcher.me/ https://mailcatcher.me/
- justboxing 9y ago[RETRACTED]. My bad.
- thegeomaster 9y agoIt appears to me that mailcatcher linked by the parent is free and open source.
- brightball 9y agoYep. Mailhog is another good one. For staging environments I like Mailtrap.io because it's a cleaner interface for non-devs.
- itake 9y agoYou get what you pay for :). mailcatcher is OSS and self hosted. Mailhog definitely looks prettier.
- emidln 9y agoI'd probably set SMTP_URI in my environment or as a java property and just use that to configure my SMTP service. While an Interface and DI might be useful for unit testing, when I'm testing in integration, ci, or qa environments, I'd want to make sure that I'm using an SMTP server that can't send emails to the outside world. Postfix is pretty easy to setup for this scenario (a whitelist of users/domains to forward mail for) so I can still test mail output.
- rqs 9y agoI was once trying to develop a SMTP sender lib for PHP. After reading a lot's of RFC's, I found it's really helpful to test my code against some standard SMTP server so I can know my code is work as expected. But a real SMTP server is not an option as they all have some kind of filters and server settings that will interfere my test, + In this case, I don't think doing TDD with a real working commercial server (i.e Gmail, Outlook etc) is a good idea. It's not only slow, but also wasting (their resources). That's when a fake SMTP server come in handy. Because not only you can use them to Send a lot's of mail, also those emails will not generate any (I hope) real world side effect.