I was setting up ELMAH to send email notifications of errors, and I discovered something interesting that caught me by surprise.
In my web.config, the elmah section was set up like so:
<elmah>
<errorMail from="[email protected]"
to="[email protected]"
subject="Error Notification"
smtpServer="localhost" />
</elmah>
This works fine on our IIS servers, and the emails are sent instantaneous. I assumed that when I ran my application in Visual Studio, ELMAH wouldn't know what to do with the localhost server since Cassini doesn't have a mail server configured. Lo and behold, I discovered when testing that theory that the error notification does in fact get sent. It takes a significantly longer amount of time (about 2 minutes, versus instantaneous on an IIS server or if I specify the mail server directly).
How does SmtpClient.Send() know which mail server to use when it's not explicitly specified?
I did some digging around with Reflector, and I suspect that it might be somewhere in SmtpTransport (possibly the GetConnection() method?).