In this article I will explain with an example, how to configure Email SMTP Settings in Web.Config file in ASP.Net.
 
 

Mail Server Settings in Web.Config file

Following are the Mail Server settings added in the Web.Config file.
The SMTP Mail settings are stored in the mailSettings sub-section of the system.net section of the Web.Config file.
Note: It is necessary to use the sender’s email address credentials while defining the Gmail SMTP Server Credentials as Gmail the sender’s email address must be same as the Gmail Username specified in credentials.
 
<system.net>
    <mailSettings>
        <smtp deliveryMethod="Network" from="sender@gmail.com"
            <network
                host="smtp.gmail.com
                port=587
                enableSsl="true
                userName="sender@gmail.com
                password="SenderGmailPassword
                defaultCredentials="true/> 
        </smtp>
    </mailSettings>
</system.net>
 
For more details on how to send Email, please refer following articles.