How to set SmtpClient properties using web.config

SmtpClient Class allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP). Instead of assigning properties of this class in C# , we can use the <> element in the web.config as shown below :

<smtp from = "">
host = ""
port = "25"
password = "password"
userName = ""
defaultCredentials = "false"
enableSsl = "true"

The advantage of this approach is that we can change the mail settings without having to rebuild the entire application.

Hope this helps 🙂

Further Reading : 
Sending Email with System.Net.Mail