Here I want to send mail using gmail smtp.But I shows error
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
on button click insted of sending mail.
html
<asp:TextBox ID="txtfrom" runat="server"></asp:TextBox>
<asp:TextBox ID="txtfrompassword" runat="server"></asp:TextBox>
<asp:TextBox ID="txtto" runat="server"></asp:TextBox>
<asp:TextBox ID="txtbody" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
code behind
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage(txtfrom.Text,txtto.Text);
msg.Body = txtbody.Text;
SmtpClient sc = new SmtpClient("smtp.gmail.com", 587);
sc.Credentials = new NetworkCredential(txtfrom.Text, txtfrompassword.Text);
sc.EnableSsl = true;
sc.Send(msg);
Response.Write("send");
}