Hi all,
i use to get error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. nj9sm25493816pbc.13 - gsmtp
when i use to click on submit button ,i am trying to send email plz help ?
Code behind:
MailMessage mail = new MailMessage();
mail.From = new MailAddress("jimitbhatt92@gmail.com","Jimit");
mail.To.Add(new MailAddress(TextBox7.Text));
mail.Subject = "Registration";
mail.Body = "Thanks for registration!";
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("jimitbhatt92@gmail.com", "*********");
try
{
smtp.Send(mail);
}
catch (SqlException)
{
Label1.Text = "Mail has not been sent";
}
web config:
<system.net>
<mailSettings>
<smtp from="jimitbhatt92@gmail.com">
<network host="smtp.gmail.com" userName="jimitbhatt92@gmail.com" password="*******" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>