My recent post on Installing the Microsoft IIS SMTP Service on Windows Server 2008 helps people get up-and-running with a local SMTP service to support the sending of emails from code (i.e.: C# Sample For Sending Emails). Just getting the SMTP service running though is only the first step – the default installation actually WON’T let you send an emails because the “relay” function is locked down tightly (effectively disabled). The very good reason for this is to keep someone from installing the service without changing the defaults and then having their server function as an open relay for spammers.
So let’s get started. You access the Microsoft SMTP service through the legacy IIS6 Management tools that were installed at the same time that the SMTP service was installed (reference my earlier post from the link above).
Once there, right-click on the SMTP Virtual Server and choose the Properties option.
From the Properties dialog window you want to access the Relay Restrictions. This controls who can (or can’t) use this SMTP service for sending email – “relaying” it from your code to a remote final destination.
By default the relay restrictions have a setting to allow “only the list below” to relay from the machine. What you need to do is to add an entry to allow 127.0.0.1 (aka “localhost” – anything sent from the local machine) as an acceptable relay source.
Clicking OK after adding it and you’ll now see it in the list as “granted” access.
Click OK a few times and you’re done! Now go test with some sample code that sends emails from the local machine and it should relay (forward) the emails on to the final destination just as expected.
Happy hosting!
Brad on Google+