title: Use App Pool Credentials to Send Email
body: <p>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. </p>
  
  <p>Our web.config looks as follows:</p>
  
  <pre><code>  &lt;smtp deliveryMethod="Network" from="support@company.com"&gt;
      &lt;network host="mail.company.com" defaultCredentials="true"/&gt;
    &lt;/smtp&gt;
  </code></pre>
  
  <p>Based on <a href="http://msdn.microsoft.com/en-us/library/ms164242%28v=vs.110%29.aspx" rel="nofollow">the msdn docs</a>, I would expect this to use the app pool credentials when sending email. However, at runtime no attempt is made to authenticate. </p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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). </p>
  
  <p>How can we configure our application to use the application pools credentials to send authenticated email?</p>