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 PowarPosted May 12, 2016, 8:38 AM
Ananth GPosted Oct 21, 2016, 5:41 AM
Rajeesh MenothPosted May 12, 2016, 10:56 AM