Hii,
i am facing the following error while sending the mail following is my code please help
“The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
thanks in advance
-----------------------------------------------------------------------------------------------
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress(txtUsername.Text);
// Recipient e-mail address.
Msg.To.Add(txtTo.Text);
Msg.Subject = txtSubject.Text;
Msg.Body = txtBody.Text;
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials=new System.Net.NetworkCredential(txtUsername.Text,txtpwd.Text);
smtp.EnableSsl = true;
smtp.Send(Msg);
Msg = null;
Page.RegisterStartupScript("UserMsg", "");
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
----------------------------------------------------------------------------------------------------------- 
Ranjit PowarRank #553 · 4.4K reputationPosted May 12, 2016, 4:38 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted May 12, 2016, 6:56 AM EDT
Ananth GRank #1,176 · 1.5K reputationPosted Oct 21, 2016, 1:41 AM EDT