The <system .net> tag in the web.config file :
Code:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="Sahil Nazir Zargar <[email protected]>">
<network host="smtp.gmail.com" enableSsl="true" userName="[email protected]" password= "******" port="6129" />
</smtp>
</mailSettings>
</system.net>
The code in the Email.aspx.cs
Code:
protected void Page_Load(object sender, EventArgs e)
{
//creating an instance of the mailmessage class form System.Net.Mail
MailMessage mymessage = new MailMessage();
// using the Mailmessage class properties
mymessage.Subject = "Test Mail";
mymessage.Body = "This is a test mail sent from Planet Sahil to check the ASP.net System.Net.mail class properties";
mymessage.From = new MailAddress("[email protected]", "Sahil Nazir Zargar");
mymessage.To.Add(new MailAddress("[email protected]", "Sahil Nazir Zargar"));
//mymessage.CC.Add (new MailAddress("[email protected]", "Sahil Zargar"));
//SmtpClient mySmtp = new SmtpClient("10.237.216.90");
SmtpClient mySmtp = new SmtpClient();
mySmtp.Send(mymessage);
}
I have already tried different port numbers such as 6129,578,100