Sending Email by SMTP IIS7 Server on Windows Server 2008

iis-7smtp

I have a website that sends out email

The C# code to do this is:

var mailClient = new SmtpClient
{
DeliveryMethod = SmtpDeliveryMethod.Network,
Host = "localhost",
Port = 25
};

mailClient.Send(_mailMsg);

The code works fine as this website deployed on a Windows Server 2003 IIS6 works perfectly.

I have configured the SMTP service in IIS7 to deliver to localhost using port 25 and set authentication settings as not required.

Would anybody have any further assistance to help in being able to send emails with iis7 and windows server 2008?

Best Answer

IIS7 SMTP is the same as IIS6 SMTP. It wasn't updated, so even the management is done with IIS 6 Manager (even though everything else is IIS7). Edit the server properties and make sure that 127.0.0.1 is added as an approved relay IP address. That will allow it to work without authenticating as long as it's sent from the local machine.

Note: That was required with IIS6 too though so possibly you did this with the IIS6 server at some point in the past.

That's the only change I make to a new IIS SMTP server to ensure that it works from the local machine. (not counting spam settings like reverse and forward DNS entries)