Possible duplicate:
The SMTP server requires a secure connection, or the client failed authentication. Server response: 5.5.1 Authentication required
I had a problem when I run this code, then an error occurred: "The SMTP server requires a secure connection or the client did not authenticate. Server response: 5.5.1 Authentication is required."
And my code is:
the code
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { MailMessage mail = new MailMessage(); mail.To.Add(" info@msslindia.com "); mail.From = new MailAddress(" info@msslindia.com "); string body = "<table><tr><td>Company Name:</td><td>" + txt_cname.Text + "</td></tr><tr><td>Address With No.:</td><td>" + txt_addwithno.Text + "</td></tr><tr><td>Contact Person:</td><td>" + txt_conperson.Text + "</td></tr><tr><td>Email Id</td><td>" + txt_email.Text + "</td></tr><tr><td>Description</td><td>" + txt_description.Text + "</td></tr></table>"; mail.Body = body; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.Credentials = new System.Net.NetworkCredential(" info@msslindia.com ", "12345"); smtp.EnableSsl = true; smtp.Send(mail); txt_cname.Focus(); txt_cname.Text = ""; txt_addwithno.Text = ""; txt_conperson.Text = ""; txt_email.Text = ""; txt_description.Text = ""; }
Sanat pandey
source share