We have an asp.net application that takes care of sending our in product emails. We would like to use the application pools account to send authenticated emails to our exchange server.
Our web.config looks as follows:
<smtp deliveryMethod="Network" from="support@company.com">
<network host="mail.company.com" defaultCredentials="true"/>
</smtp>
Based on the msdn docs, I would expect this to use the app pool credentials when sending email. However, at runtime no attempt is made to authenticate.
Digging into the System.Net code, it looks like the defaultCredentials option will cause us to use the CredentialCache.DefaultCredentials property, which populates credentials with an empty username and password. Thus, this may be the cause of the issue.
Due to security concerns, we do not want to populate an explicit username and password within the smtp configuration section. We do not want to use an open relay at all (which is what we are currently using), because we do not have a way to throttle or stop email.
We would like the app pool to authenticate, so we can disable the mailbox in the situation where our application encounters and error and spams us with email (which has already happened).
How can we configure our application to use the application pools credentials to send authenticated email?