Need to read my SMTP email settings defined under system.net section in my web.config file.
Below is one example of SMTP email setting defined in web.config file: (Under Section)
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="[email protected]">
<network defaultCredentials="true" host="localhost" port="25" userName="user” password="testPassword"/>
</smtp>
</mailSettings>
</system.net>
How to Access the SMTP Mail Setting by using c#
Reading SMTP Mail Settings from Web.Config file in ASP.Net Then an object of the SmtpClient class is created and the settings of the Mail Server such has Host, Port, DefaultCredentials, EnableSsl, Username and Password are fetched from the mailSettings section of the Web.
Allows applications to send email by using the Simple Mail Transfer Protocol (SMTP). The SmtpClient type is obsolete on some platforms and not recommended on others; for more information, see the Remarks section.
Just use the System.Net.Mail
classes to send your e-mails. It will automagically pick-up the Mail setting from your web.config.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With