Okay picture this: You’re building your awesome web app and suddenly, you have to verify that emails are being sent properly. You’d want some kind of app that would drop emails in a folder, right?
If you were on Windows, that would be fairly easy. Just hit a web search and install one of the many dummy SMTP servers out there.
But you’re probably on Linux (why else would you be reading this). And on Linux, there is no such app. You’ll have to hack your way out of this.
Well not anymore. Thanks to this awesome script by Stuart Colville, I was able to create a dummy SMTP server in Python. I’ve posted the code on github :
https://github.com/jevin/Dummy-SMTP
It’s really simple to use :
- Download the .zip
- Extract it
- Make “listen.py” executable
- Kill any process using port 25 (usually “sudo pkill sendmail” is enough)
- Type “sudo ./listen.py” on your console
- Tada! All emails sent will be dropped in the “mails” folder.
I’ve only tested this with Sendmail. So if you see something weird with other MTAs, let me know!
May 1, 2012 at 7:13 am
Awesome! Really interested in trying it out. Out of curiosity, why not just tar and gzip the file to preserve the executable permissions? I’d say this is more or less the norm on Linux.
May 1, 2012 at 7:37 am
Because github.
It’s easier to keep my source code there, with all the versioning and what not.
May 1, 2012 at 8:32 am
Github allows you to download gzipped tarballs https://github.com/jevin/Dummy-SMTP/tarball/master
May 1, 2012 at 7:14 am
Also curious why the choice of MTA would make any difference.
May 1, 2012 at 7:41 am
I don’t think it will make any difference. But, since I never worked with anything other than Sendmail, I’m not very sure. These MTAs can be a pain at times!
May 1, 2012 at 8:32 am
I just don’t see why there would be any interaction with the MTA whatsoever.
Pingback: An SMTP server for testing | Thought Flow