I am trying to set up SMTP server on IIS 7. I have selected "Deliver e-mail to SMTP server", and "Use localhost" checkmark and the port number is set to 25. My c# code is below

protected void Page_Load(object sender, EventArgs e)
    SmtpMail.SmtpServer = "localhost";
    SmtpMail.Send("FROM", "TO", "SUBJECT", "BODY");

I am getting a error saying "The transport failed to connect to the server". Need help to fix this problem.


Can you communicate with the SMTP server via telnet to ensure it's up and running and accepting connections?


The SMTP service is not enabled by default so you have to explicitly install it.

http://www.jppinto.com/index.php/2009/02/installing-iis-70-with-smtp-on-windows-server-2008/ (scroll down to the section titled "SMTP Installation")

Once that is installed, you should see an IIS 6.0 Manager in your Admin tools. You will need to use that to configure it as SMTP cannot be configured using the IIS7 console.

After you do that, your code above should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.