替代品进行测试SMTP? [英] Alternatives for testing SMTP?
问题描述
我想开发一个应用程序,发送电子邮件,和我们的内部网络被锁定pretty的紧,所以我不能中继使用我们的内部邮件服务器。
I'm trying to develop an app that sends email, and our internal network is locked down pretty tight, so I can't relay using our internal mail servers.
有没有人使用过类似no-ip.com?还有没有其他办法?
Has anyone ever used something like no-ip.com? Are there any other alternatives?
推荐答案
如果你只需要检查电子邮件被发送到正确的地址,并用正确的内容,最简单的方法是使用投递文件夹通过编辑应用程序或web.config文件:
If you just need to check that the e-mails are being sent to the correct addresses and with the correct contents, the easiest way is to use a drop folder by editing the app or web.config file:
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory" from="me@myorg.com">
<specifiedPickupDirectory pickupDirectoryLocation="C:\TestMailDrop"/>
</smtp>
</mailSettings>
</system.net>
这将导致邮件被创建为在指定目录下的文件。你甚至可以再加载的文件,并验证它们作为一个单元测试的一部分。
This will result in the e-mails being created as files in the specified directory. You can even then load the files and verify them as part of a unit test.
(如codekaizen指出,这也可以在code做,如果你不介意修改code /硬编码的投递文件夹,并具有不同的行为在调试/释放模式。 )
(As codekaizen points out, this can also be done in code if you don't mind modifying the code/hardcoding the drop folder and having the behavior differing in debug/release mode.)
这篇关于替代品进行测试SMTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!