Tuesday 20 January 2015

When we sending mail if you trouble shooting with this Error

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at + working on one gmail account.

To solve this Error just go to this links

https://accounts.google.com/DisplayUnlockCaptcha
https://www.google.com/settings/security/lesssecureapps

Code for Sending Email:

System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
        mail.To.Add("Toaddress");
        mail.From = new MailAddress("from mail", "Email head", System.Text.Encoding.UTF8);
        mail.Subject = "This mail is send from asp.net application";
        mail.SubjectEncoding = System.Text.Encoding.UTF8;
        mail.Body = "This is Email Body Text";
        mail.BodyEncoding = System.Text.Encoding.UTF8;
        mail.IsBodyHtml = true;
        mail.Priority = MailPriority.High;

        SmtpClient client = new SmtpClient();
       // client.EnableSsl = true;
        client.UseDefaultCredentials = false;

        client.Credentials = new System.Net.NetworkCredential("from mail", "from mail Password");
        client.Port = 587;
        client.Host = "smtp.gmail.com";
        client.EnableSsl = true;
       
        try
        {
            client.Send(mail);
        }
        catch (Exception ex)
        {
            throw;

        }

Reference Link:
http://forums.asp.net/t/2021213.aspx?sending+email+via+gmail+not+working+authentication+problem

If you have any Queries please contact lakshmibindu.cse@gmail.com