Method for email testing

2019-01-31 17:22发布

I am writing a program that will be emailing reports out many (~100) clients which I want to test before I spam everyone.

I want to do a test run against my production data and actually send the messages to a SMTP server, but I don't want the SMTP server to actually deliver the messages. I want the server to act like a real SMTP server from the perspective of my application, but instead of delivering messages, I just want it to store the messages, and log what happened.

Is there a SMTP server specifically designed for testing purposes?

Does anyone know of a way to configure exim or postfix to behave like I have described above

What do you use to test a mass-email delivery?

14条回答
何必那么认真
2楼-- · 2019-01-31 17:51

I personally modify the e-mail addresses to test, I send them to a dummy account of mine, that way I can validate not only that they sent, but that they appear in the proper format.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-31 17:54

Exim can be configured to accept incoming mails but not deliver them. Look for the keywords queue_only and queue_only_file in the documentation.

查看更多
狗以群分
4楼-- · 2019-01-31 17:55

Post Hoc is a pure Java application that looks exactly like an SMTP server to the application you are testing, but it simply collects all the email messages and allows you to inspect them using a web interface.

Freely available at: Post Hoc GitHub Site

For more information: PostHoc: Testing Apps that Send Email

查看更多
ら.Afraid
5楼-- · 2019-01-31 17:58

In java you can use dumbster

Its easy to use and you can validate every aspect of the email you are intercepting.

It's a Java SMTP server implementation meant for unit testing. (Just make sure you redirect your email to the machine running dumbster...)


I just found another alternative that do almost the same: Greenmail

Greenmail also support POP3, IMAP with SSL so you can test your client against it.

查看更多
三岁会撩人
6楼-- · 2019-01-31 17:58

"The Wiser framework for unit testing mail"

I've heard of a few other developers moving from Dumbster to Wiser and have migrated my testing code as well. One of the Java components that I've worked on sends thousands of emails a day and I've written unit tests for the different email templates and scenarios using Dumbster and Wiser. I prefer Wiser.

Snips from the Wiser website (http://code.google.com/p/subethasmtp/wiki/Wiser):

Wiser is a smart replacement for Dumbster and is built on top of the SubEtha SMTP Java library which allows your Java application to receive SMTP mail with a simple, easy-to-understand API.

查看更多
登录 后发表回答