A simple local SMTP server [closed]

落花浮王杯 提交于 2019-12-28 05:16:13

问题


I want to test a Java code for sending email. I don't want to use any commercial mail client or connect to any external mail providers (like Gmail or Yahoo). I would like to know if there is any software which allows a user to configure dummy email addresses and server (locally) which can be used in my software to send and receive mails. I just want to test the functionality of the Java code.


回答1:


For email testing, try Dumbster. From their page:

The Dumbster is a very simple fake SMTP server designed for unit and system testing applications that send email messages. It responds to all standard SMTP commands but does not deliver messages to the user. The messages are stored within the Dumbster for later extraction and verification.

The Dumbster slots itself very easily into your testing strategy. As long as your application talks to an email server using SMTP then the Dumbster can be used to test the application with no code changes.

Various forks exist since the original page is no longer available:

  • https://github.com/kirviq/dumbster
  • https://github.com/rjo1970/dumbster

More can be found using a Github Search




回答2:


I prefer Fake SMTP for this. It's a desktop app (packed into jar file). Since it is written in Java, you can run it both from Linux/Mac/Windows




回答3:


You can use Wiser in the SubEthaSMTP library, Wiser's purpose is exactly what you want, unit testing.




回答4:


Try GreenMail. It's geared towards JUnit usage, but it should do what you need. You can run it in a JBoss instance or have your JUnit tests send mail to themselves, depending on your specific needs.

There are a few other similar bits of software out there, but that's the one I've used and was reasonably happy with it.




回答5:


on Leopard you can start a Local SMTP Server (Postfix) on OS-X Leopard

sudo vi /System/Library/LaunchDaemons/org.postfix.master.plist

before the closing tag at the end:

<key>RunAtLoad</key> <true/> <key>KeepAlive</key> <true/>

then start the thing with

sudo postfix start

now you check wheter the service is running with:

telnet localhost 25



回答6:


The javamail-file-transport saves emails to files instead of sending them through SMTP server.

See the javaMail extensions project on GitHub.

It adds file transport that allows:

  • save mails to files in text format instead of sending them
  • save mails to files in mbox format instead of sending them
  • add log info instead of sending email



回答7:


I've used Mailtrap a few times, and I can recommend it.




回答8:


use the Aspirin From the docs: Aspirin is an embeddable send-only SMTP server for Java developers.




回答9:


amazing docker
https://hub.docker.com/r/mailhog/mailhog/
(gitHub - https://github.com/mailhog/MailHog)
This docker has two ports:
One port for sending SMTP e-mails (smtp://0.0.0.0:1025/)
A second port to the e-mail display on the web (http://0.0.0.0:8025/)

run docker:
docker pull mailhog/mailhog
docker run --name=mailhog -d -p 1025:1025 -p 8025:8025 mailhog/mailhog




回答10:


You can use smtp4dev. Please find out more details here.



来源:https://stackoverflow.com/questions/8599791/a-simple-local-smtp-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!