如何通过 IIS7 发送电子邮件? [英] How to send email through IIS7?

查看:39
本文介绍了如何通过 IIS7 发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 Windows 7 机器上使用 IIS7 设置 SMTP 服务器.我已将其设置为将电子邮件发送到 localhost,端口 25,没有身份验证.但是当我尝试从我的 C# 程序以编程方式连接时,我收到一个错误:

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:

发送邮件失败",内部异常无法建立连接,因为目标机器主动拒绝了它127.0.0.1:25

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?

推荐答案

我发现最好的方法是使用 SMTP4Dev,它会侦听电子邮件,并向您显示已发送"的内容,但实际上并未发送任何内容.非常适合测试!

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆