TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: A fake SMTP server for software integration testing

127 点作者 aeaa310 个月前
This is a side project of mine.<p>Use this as your SMTP server in a test environment to guarantee that your users don&#x27;t receive test emails.<p>Looking for feedback, especially on the security side.

19 条评论

snikch10 个月前
I have used tools like these for nearly a decade and find them invaluable. My current favourite is Mailpit [1].<p>The “OG” I would consider Mailcatcher [2] from my Rails days<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;axllent&#x2F;mailpit">https:&#x2F;&#x2F;github.com&#x2F;axllent&#x2F;mailpit</a><p>[2] <a href="https:&#x2F;&#x2F;mailcatcher.me&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mailcatcher.me&#x2F;</a>
评论 #41029919 未加载
评论 #41071101 未加载
评论 #41088761 未加载
duskwuff10 个月前
I prefer self-hosting MailHog:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;mailhog&#x2F;MailHog">https:&#x2F;&#x2F;github.com&#x2F;mailhog&#x2F;MailHog</a>
评论 #41028327 未加载
评论 #41030696 未加载
评论 #41034998 未加载
评论 #41028273 未加载
评论 #41037787 未加载
sethammons10 个月前
since folks are sharing tools they use to test, I have one to validate if your email sender can send internationalized emails<p>pünicode.com. Any local part will create a temp cache that you can check to see if your email system can deliver to international local and&#x2F;or domain parts. EG, send an email to josé@pünicode.com and see it show up at pünicode.com&#x2F;emails&#x2F;josé.
tzs10 个月前
Wow...I didn&#x27;t realize there were so many of these. People have mentioned almost a dozen in the comments so far.<p>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.<p>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 &quot;220 hello&quot; message, and then loops reading what they send. Everything they send is copied to the file.<p>If they send a &quot;quit&quot; command it sends back &quot;221 bye&quot; and disconnects and closed the output file.<p>If they send a &quot;data&quot; command it sends back &quot;354 send the message&quot; and then loops until they send a &quot;.&quot; line. When they send that it sends back &quot;250 OK&quot;.<p>If they send anything else it just says &quot;250 OK&quot;.<p>That ridiculously small subset of SMTP turns out to be fine in my environment.<p>Here it is in case anyone might actually find it useful [1]. Building and running is simple. It&#x27;s a single Java file, SmtpSink.java. Put that somewhere, &quot;mkdir msgs&quot; there, &quot;javac SmtpSink.java&quot;, and then &quot;java SmtpSink&quot;. The data for each connection will be in the msgs directory.<p>[1] <a href="https:&#x2F;&#x2F;pastebin.com&#x2F;dqgGZB82" rel="nofollow">https:&#x2F;&#x2F;pastebin.com&#x2F;dqgGZB82</a>
SoftTalker10 个月前
If &quot;my users&quot; might receive test emails, that means I&#x27;m using real user email addresses in my test data, therfore my test SMTP server should not be a random system on the internet but something I fully control.
评论 #41030597 未加载
aeaa310 个月前
A little more information:<p>So, it&#x27;s called fakemail but there is a real SMTP server in there. Attachments should work fine. Getting the web app to create SMTP accounts was quite tricky, I&#x27;m sure there are better ways but I ended up implementing the unix crypt() algorithm in C#.<p>Server is holding up fine so far (there was a rate-limiting bug which brought the site down yesterday). Logs show 37K unique IPs have accessed it since yesterday, and it seems to be using about 1% of the CPU (it&#x27;s on a free VM in the Oracle Cloud).<p>There is a whole API sitting behind the web page, including proper authentication, but the frontend is very much a MVP.<p>Very few actual emails have been sent to it, so I&#x27;d love it if people could actually send stuff. There are a bunch of websites that can be used to send test mails, e.g.<p><a href="https:&#x2F;&#x2F;www.gmass.co&#x2F;smtp-test" rel="nofollow">https:&#x2F;&#x2F;www.gmass.co&#x2F;smtp-test</a><p><a href="https:&#x2F;&#x2F;www.smtper.net&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.smtper.net&#x2F;</a><p><a href="https:&#x2F;&#x2F;smtpserver.com&#x2F;smtptest" rel="nofollow">https:&#x2F;&#x2F;smtpserver.com&#x2F;smtptest</a><p><a href="https:&#x2F;&#x2F;dnschecker.org&#x2F;smtp-test-tool.php" rel="nofollow">https:&#x2F;&#x2F;dnschecker.org&#x2F;smtp-test-tool.php</a>
jallmann10 个月前
Also built something very similar - <a href="https:&#x2F;&#x2F;ephemeralpostal.com" rel="nofollow">https:&#x2F;&#x2F;ephemeralpostal.com</a><p>Comes with a small API so your integration tests can actually check the contents of emails that were expected to be sent out. Did a Show HN a while ago with more details - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40590670">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40590670</a>
netsec198910 个月前
Wow, this and all the various other options mentioned look very useful. Like others, I have hacked together configurations to do this in the past and would have loved to have these instead.<p>I had no idea on the availability of all the various options, which leads to the question: Where would one find examples of similar network test servers for other protocols&#x2F;functions?<p>For example:<p>- A SAML IdP - Define accounts and complete a login, allow debug of request&#x2F;response.<p>- A DNS Server - Define local domains and records, control whether Internet domains are resolvable or just local ‘corporate’ records.<p>- Syslog Server - Catch logs and make them temporarily available. (usually syslogd works for this, but maybe test harnesses have advantages).<p>- SNMP - Trap destination to capture&#x2F;show alerts
dboreham10 个月前
I have a rule that any time someone ships a server, they&#x27;re required to also ship a version that supports client testing purposes.<p>Of course nobody has ever observed my rule.<p>Doesn&#x27;t make it a bad rule...
评论 #41064813 未加载
评论 #41054404 未加载
politelemon10 个月前
Since it seems to be overwhelmed currently, I&#x27;d suggest letting users host their own version of this in their own networks.
abound10 个月前
I recently came across MailSlurper [1], which I think serves a similar use case.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;mailslurper&#x2F;mailslurper">https:&#x2F;&#x2F;github.com&#x2F;mailslurper&#x2F;mailslurper</a>
aeaa310 个月前
This is all open source by the way, and can be self-hosted. All the code is at <a href="https:&#x2F;&#x2F;github.com&#x2F;aled&#x2F;fakemail">https:&#x2F;&#x2F;github.com&#x2F;aled&#x2F;fakemail</a>.
sam_perez10 个月前
Really cool. I couldn&#x27;t find it documented anywhere, but if you save the unique (guid) url generated, how long is that available for? &quot;Forever&quot;?
评论 #41043700 未加载
mandeepj10 个月前
On the real one, you can set it to -&#x27;save emails to filesystem instead of sending out&#x27;, so a fake SMTP is not really required.
rietta10 个月前
I use dockerized mailcatcher for this. Used it for years with ruby on rails and now use it for everything.
TomasEkeli10 个月前
hugged to death?<p>anyway - i got a great 429 back with a suggested try-after -time. it made me smile in appreciation!<p>well done!
评论 #41028636 未加载
bbarnett10 个月前
I don&#x27;t want to burst bubbles, but postfix with few lines of config can redirect all email to DEVs.<p>You really want, whenever possible, to test everything using real tools. Doubly so, using tools you&#x27;ll use it PROD. However, at least postfix is de-facto standard.<p>apt-get install postfix, postfix-pcre bsd-mailx, config and done.<p>Here&#x27;s an example redirecting ALL outgoing emails, UNLESS they are to your OK domains. Redirects are sent to an alias in &#x2F;etc&#x2F;aliases, which you can point to anything. (Easier for DEVs to modify when required)...<p><pre><code> &#x2F;etc&#x2F;postfix&#x2F;header_checks (adds a header with original TO) &#x2F;^(.*)@((?:(?![^\.]+.corp-domain1.com|anotherdomain.ca|localhost).)*)$&#x2F; PREPEND DEV-ENV-REDIRECT: ${1}@${2} </code></pre> This MUST be the same as the above regex, so that the TO preservation + redirect are both done in tandem..<p><pre><code> &#x2F;etc&#x2F;postfix&#x2F;recipient_canonical_map &#x2F;^(.*)@((?:(?![^\.]+.corp-domain1.com|anotherdomain.ca|localhost).)*)$&#x2F; externalredirect@localhost </code></pre> Then in main.cf<p><pre><code> # added recipient_canonical_classes = envelope_recipient recipient_canonical_maps = pcre:&#x2F;etc&#x2F;postfix&#x2F;recipient_canonical_map local_header_rewrite_clients = permit_mynetworks # header_checks = pcre:&#x2F;etc&#x2F;postfix&#x2F;header_checks </code></pre> Then in &#x2F;etc&#x2F;aliases:<p><pre><code> # externalredirect: dev # dev&#x27;s email.. (default unless set) dev: &#x2F;dev&#x2F;null </code></pre> Preserving the original TO as another header ensures you can debug if required, whilst preserving 100% the original mail body.<p>Using a second redirect in aliases, allows you do something such as:<p>&#x2F;etc&#x2F;aliases:<p><pre><code> # externalredirect: dev, another_email_address_for_logs # dev&#x27;s email.. (default unless set) dev: &#x2F;dev&#x2F;null </code></pre> So it&#x27;s super easy for a dev to just change:<p><pre><code> dev: &#x2F;dev&#x2F;null </code></pre> to<p><pre><code> dev: dev@corp.com </code></pre> Without the need to worry about overall redirect stuff.<p>NOTE that if you don&#x27;t have a unique email for your company&#x27;s DEVs to use, this won&#x27;t work, HOWEVER... you can redirect with more refined controls above.<p>That is, instead of saying &quot;if it&#x27;s not to a company domain, then redirect this DEV TEST email!&quot;, you can &quot;If not to this specific email address, then redirect to this specific email address&quot;.<p>The reason I have this setup to redirect of not corp domain, is that the env I have this deployed in is byte per byte 100% identical to PROD deployment, with only very, very, very, minor tweaks. About 20 bytes or so.<p>That way, all tests done in DEV are 100% identical to configs in PROD. You eliminate PROD deploy bugs more aptly this way. And so if local MTAs are postfix in PROD, then you can keep all of your PROD postfix configs, with these minor changes to lock down DEV. And, you can keep the all the config files, all the config, and just have empty header_checks, recipient_canonical_map files.<p>But this means that alert emails that might get send from PROD have genericized domains, so in such envs it&#x27;s easier to NOT redirect corp dest emails carte blanche, and then send everything else to a redirect dest.<p>That way monitoring &#x2F; emerg emails get through unvarnished.
评论 #41031819 未加载
评论 #41032034 未加载
评论 #41031719 未加载
jackthemuss10 个月前
I use MailSlurp
atum4710 个月前
Down for me