title: How to send email through IIS7?
body: <p>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:</p>
  
  <blockquote>
    <p>Failure sending mail", inner exception "No connection could be made because the target machine actively refused it 127.0.0.1:25</p>
  </blockquote>
  
  <pre><code>public static void SendEmail(MailMessage m) {
    var smtp = new SmtpClient {
      Host = "localhost",
      Port = 25,
      UseDefaultCredentials = true,
    };
    smtp.Send(m);
  }
  </code></pre>
  
  <p>Why?  What other secret switch do I have to flip?</p>