Hacker News new | ask | show | jobs
by tzs 703 days ago
Wow...I didn't realize there were so many of these. People have mentioned almost a dozen in the comments so far.

I too have one, but it is very barebones. No GUI, no API. I suspect it would fail in many cases that the others handle, but it is fine for my test environment. That environment is basically a bunch of services from work that in production run on separate servers all shoved into one test VM with a firewall that blocks most outgoing connections to keep things from escaping.

The firewall reroutes any attempted outgoing port 25 connections to localhost port 2000, which my fake SMTP server listens on. When something connections it creates a timestamped file, sends them a "220 hello" message, and then loops reading what they send. Everything they send is copied to the file.

If they send a "quit" command it sends back "221 bye" and disconnects and closed the output file.

If they send a "data" command it sends back "354 send the message" and then loops until they send a "." line. When they send that it sends back "250 OK".

If they send anything else it just says "250 OK".

That ridiculously small subset of SMTP turns out to be fine in my environment.

Here it is in case anyone might actually find it useful [1]. Building and running is simple. It's a single Java file, SmtpSink.java. Put that somewhere, "mkdir msgs" there, "javac SmtpSink.java", and then "java SmtpSink". The data for each connection will be in the msgs directory.

[1] https://pastebin.com/dqgGZB82