How does my ASP.NET app get the SMTP settings automatically from web.config?

Posted by Ryan on Stack Overflow See other posts from Stack Overflow or by Ryan
Published on 2010-05-04T17:21:11Z Indexed on 2010/05/04 17:28 UTC
Read the original article Hit count: 233

Filed under:
|
|
|

I noticed that we always just are like:

SmtpClient mSmtpClient = new SmtpClient();
// Send the mail message
mSmtpClient.Send(mMailMessage);

And the only place the credentials are set are in web.config:

  <system.net>
    <mailSettings>
      <smtp>
        <network host="xxx.xx.xxx.229" userName="xxxxxxxx" password="xxxxxxxx"/>
      </smtp>
    </mailSettings>
  </system.net>

So my question is, how does it automagically get them out?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET