如何通过IIS7发送电子邮件? [英] How to send email through IIS7?
问题描述
我试图建立一个SMTP服务器,我的Windows 7机器上IIS7。我已经将它设置为传送电子邮件到本地主机,端口25,没有任何身份验证,但是当我尝试从我的C#程序编程连接时,我得到一个错误:
发送邮件失败,内部异常没有连接可以作出,因为目标机器积极地拒绝它127.0.0.1:25
块引用>
公共静态无效SendEmail(MAILMESSAGE米){
变种SMTP =新SmtpClient {
主机=localhost,则
端口= 25,
UseDefaultCredentials = TRUE,
};
smtp.Send(M);
}
为什么呢?我有什么其他的秘密开关翻转?
解决方案最好的方法,我发现是使用 SMTP4Dev ,该侦听邮件,并显示出你做了什么派,但实际上并没有发送任何东西。对于大测试!
I'm trying to set up a SMTP server on my Windows 7 machine in IIS7. I have set it to "Deliver email to localhost, port 25, no authentication. But when I try to connect programmatically from my C# program, I get an error:
Failure sending mail", inner exception "No connection could be made because the target machine actively refused it 127.0.0.1:25
public static void SendEmail(MailMessage m) { var smtp = new SmtpClient { Host = "localhost", Port = 25, UseDefaultCredentials = true, }; smtp.Send(m); }
Why? What other secret switch do I have to flip?
解决方案Best method I found was to use SMTP4Dev, which listens for emails, and shows you what was "sent", but doesn't actually send anything. Great for testing!
这篇关于如何通过IIS7发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!