Take the 2-minute tour ×

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.

share|improve this question

migrated from stackoverflow.com Apr 1 '11 at 15:23

This question came from our site for professional and enthusiast programmers.

2 Answers 2

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

share|improve this answer

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.

share|improve this answer

Your Answer


