Working on an app with notification via e-mail. I'd like to run test with out sending e-mails to production servers and clients. A couple years ago I remember someone bringing down our exchange server with a bad e-mail loop and would prefer to not repeat...
通过电子邮件处理通知应用程序。我想在不向生产服务器和客户发送电子邮件的情况下运行测试。几年前我记得有人用糟糕的电子邮件循环打倒我们的交换服务器,并且不想重复...
Any suggestion for a dev setup? Currently think a simple SMTP server will do the job but I'm not familiar with that space. I would need the ability to see all the emails sent to the server but they should never be delivered.
有关开发设置的任何建议吗?目前认为一个简单的SMTP服务器将完成这项工作,但我不熟悉这个空间。我需要能够查看发送到服务器的所有电子邮件,但它们永远不会被发送。
Thanks.
6 个解决方案
#1
18
Papercut is the perfect fit for what you are looking for. It has been publicly available for the last couple of months. I have been using it for a month. It couldn't get any easier to test email functionality.
Papercut非常适合您的需求。它在过去几个月已公开发布。我已经使用了一个月。它无法更轻松地测试电子邮件功能。
- Download Papercut.
- Run Papercut, while running it sits in your tray.
- Configure your application's smtp host to the machine running Papercut.
- Watch Papercut receive the emails and view the contents.
- When you are done. Close Papercut.
运行剪纸,同时运行它放在托盘中。
将应用程序的smtp主机配置为运行Papercut的计算机。
Watch Papercut接收电子邮件并查看内容。
当你完成。关闭Papercut。
#2
5
It's pretty simple to set up an alias that is delivered to a file instead of through any delivery mechanism in any of the major Unix/Linux mail servers like Postfix or Sendmail. During the testing, you can tail that file to see that the mail is getting send when you expect it to. After your testing is over, you can re-direct it to where-ever it's really supposed to go.
设置一个传递给文件的别名非常简单,而不是通过任何主要Unix / Linux邮件服务器(如Postfix或Sendmail)中的任何传递机制。在测试期间,您可以拖尾该文件以查看邮件是否在您预期发送时发送。测试结束后,您可以将其重定向到真正应该去的地方。
#3
1
Depending on what your email mechanism is, another alternative would be to make a testmail.(py,php,sh) script that records all arguments provided and dumps them into a tag table with event time stamps. It's not elegant, but would do for debugging. Trick all depends on how you send email.
根据您的电子邮件机制,另一种方法是制作一个testmail。(py,php,sh)脚本,记录所有提供的参数并将它们转储到带有事件时间戳的标记表中。它不优雅,但可以用于调试。欺骗一切取决于你如何发送电子邮件。
Along the same lines, if you use smtp and not sendmail, is write a ghetto app that listens on some high range port number and just dumbly responds back with the correct values.
沿着同样的路线,如果你使用smtp而不是sendmail,那就是编写一个监听一些高端端口号的贫民窟应用程序,只是用正确的值来回应。
#4
1
Your question didn't describe the environment, but if you are using an OO language (e.g. Java) you could use dependency injection. Write a MessageSender
interface with two implementations; one (EmailMessageSender
) actually sends emails, while the other (FileMessageSender
) captures the message in a string.
您的问题没有描述环境,但如果您使用的是OO语言(例如Java),则可以使用依赖注入。编写一个带有两个实现的MessageSender接口;一个(EmailMessageSender)实际发送电子邮件,而另一个(FileMessageSender)以字符串形式捕获消息。
Write and test EmailMessageSender
in isolation; once it's verified, put it on the shelf.
单独编写和测试EmailMessageSender;一旦验证,就把它放在架子上。
Write the other parts of the system against MessageSender
and test them using an (injected) instance of FileMessageSender
. (If FileMessageSender
also allows retrieval of the "sent message" content, then you can use it in unit testing.)
使用MessageSender写入系统的其他部分,并使用(注入的)FileMessageSender实例对其进行测试。 (如果FileMessageSender还允许检索“已发送消息”内容,则可以在单元测试中使用它。)
Once you've verified the rest of the system, deploy it using (again via injection) a properly-configured instance of EmailMessageSender
.
一旦验证了系统的其余部分,请使用(通过注入)正确配置的EmailMessageSender实例进行部署。
#5
1
You can use Mailtrap. You can setup that on your staging server or development server. It is easy to use and you can use production email address as well. All email will get trapped in to mailtrap's email inbox. It's easier to setup.
您可以使用Mailtrap。您可以在登台服务器或开发服务器上设置它。它易于使用,您也可以使用生产电子邮件地址。所有电子邮件都将被困在mailtrap的电子邮件收件箱中。它更容易设置。
#6
0
Why not simply spit the email list out to a text file and disconnect any calls to the mail Server?
为什么不简单地将电子邮件列表吐出到文本文件并断开对邮件服务器的任何调用?
#1
18
Papercut is the perfect fit for what you are looking for. It has been publicly available for the last couple of months. I have been using it for a month. It couldn't get any easier to test email functionality.
Papercut非常适合您的需求。它在过去几个月已公开发布。我已经使用了一个月。它无法更轻松地测试电子邮件功能。
- Download Papercut.
- Run Papercut, while running it sits in your tray.
- Configure your application's smtp host to the machine running Papercut.
- Watch Papercut receive the emails and view the contents.
- When you are done. Close Papercut.
运行剪纸,同时运行它放在托盘中。
将应用程序的smtp主机配置为运行Papercut的计算机。
Watch Papercut接收电子邮件并查看内容。
当你完成。关闭Papercut。
#2
5
It's pretty simple to set up an alias that is delivered to a file instead of through any delivery mechanism in any of the major Unix/Linux mail servers like Postfix or Sendmail. During the testing, you can tail that file to see that the mail is getting send when you expect it to. After your testing is over, you can re-direct it to where-ever it's really supposed to go.
设置一个传递给文件的别名非常简单,而不是通过任何主要Unix / Linux邮件服务器(如Postfix或Sendmail)中的任何传递机制。在测试期间,您可以拖尾该文件以查看邮件是否在您预期发送时发送。测试结束后,您可以将其重定向到真正应该去的地方。
#3
1
Depending on what your email mechanism is, another alternative would be to make a testmail.(py,php,sh) script that records all arguments provided and dumps them into a tag table with event time stamps. It's not elegant, but would do for debugging. Trick all depends on how you send email.
根据您的电子邮件机制,另一种方法是制作一个testmail。(py,php,sh)脚本,记录所有提供的参数并将它们转储到带有事件时间戳的标记表中。它不优雅,但可以用于调试。欺骗一切取决于你如何发送电子邮件。
Along the same lines, if you use smtp and not sendmail, is write a ghetto app that listens on some high range port number and just dumbly responds back with the correct values.
沿着同样的路线,如果你使用smtp而不是sendmail,那就是编写一个监听一些高端端口号的贫民窟应用程序,只是用正确的值来回应。
#4
1
Your question didn't describe the environment, but if you are using an OO language (e.g. Java) you could use dependency injection. Write a MessageSender
interface with two implementations; one (EmailMessageSender
) actually sends emails, while the other (FileMessageSender
) captures the message in a string.
您的问题没有描述环境,但如果您使用的是OO语言(例如Java),则可以使用依赖注入。编写一个带有两个实现的MessageSender接口;一个(EmailMessageSender)实际发送电子邮件,而另一个(FileMessageSender)以字符串形式捕获消息。
Write and test EmailMessageSender
in isolation; once it's verified, put it on the shelf.
单独编写和测试EmailMessageSender;一旦验证,就把它放在架子上。
Write the other parts of the system against MessageSender
and test them using an (injected) instance of FileMessageSender
. (If FileMessageSender
also allows retrieval of the "sent message" content, then you can use it in unit testing.)
使用MessageSender写入系统的其他部分,并使用(注入的)FileMessageSender实例对其进行测试。 (如果FileMessageSender还允许检索“已发送消息”内容,则可以在单元测试中使用它。)
Once you've verified the rest of the system, deploy it using (again via injection) a properly-configured instance of EmailMessageSender
.
一旦验证了系统的其余部分,请使用(通过注入)正确配置的EmailMessageSender实例进行部署。
#5
1
You can use Mailtrap. You can setup that on your staging server or development server. It is easy to use and you can use production email address as well. All email will get trapped in to mailtrap's email inbox. It's easier to setup.
您可以使用Mailtrap。您可以在登台服务器或开发服务器上设置它。它易于使用,您也可以使用生产电子邮件地址。所有电子邮件都将被困在mailtrap的电子邮件收件箱中。它更容易设置。
#6
0
Why not simply spit the email list out to a text file and disconnect any calls to the mail Server?
为什么不简单地将电子邮件列表吐出到文本文件并断开对邮件服务器的任何调用?