I was working on MVC (C#) application sending email through Gmail Server, meanwhile popped up me issue the server response was 5.5.1 authentication required, So we required action to set on security issue which is default off in Gmail Email settings. I have published an article on How to send SMS using C#, now a days it has become very necessary to integrate SMS API into our application.

Error Description

An exception of type 'System.Net.Mail.SmtpException' occurred in System.dll but was not handled in user code
Additional information: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

Gmail Code Snippet

Below is the code snippet using to send Email through Gmail Host:
public JsonResult SendEmail(string _name, string _phone, string _email, string _description)
    string senderID = "";
    string senderPassword = "demo#123";
    string result = "Email Sent Successfully";

    string body = " " + _name + " has sent an email from " + _email;
    body += "Phone : " + _phone;
    body += _description;
      MailMessage mail = new MailMessage();
      mail.From = new MailAddress(senderID);
      mail.Subject = "My Test Email!";
      mail.Body = body;
      mail.IsBodyHtml = true;
      SmtpClient smtp = new SmtpClient();
      smtp.Host = ""; //Or Your SMTP Server Address
      smtp.Credentials = new System.Net.NetworkCredential(senderID, senderPassword);
      smtp.Port = 587;
      smtp.EnableSsl = true;
    catch (Exception ex)
       result = "problem occurred";
       Response.Write("Exception in sendEmail:" + ex.Message);
    return Json(result);

First login into Gmail Account from which Gmail credentials are you using to send email.

Now go to Gmail Settings Feature, it comes in your Gmail Inbox on right side, as you see in picture below. 
Gmail Settings

Move to Security Feature

Now click on Gmail Setting Feature, move to security feature or alternatively can hit/paste this URL in your browser where you can see settings. 

Access for less secure apps

  1. Turn off (default) 
  2. Turn On  
Access for less secure apps

Click on Turn On option to authorize emails sending through while programming (MVC, C#, PHP, Java etc.) with required credentials in Gmail account.

Video: Authentication the Server Response was 5.5.1 Authentication required in gmail


Above will help to resolve issue the server response was 5.5.1 authentication required while sending email through Gmail credentials in programming languages like ASP.Net, MVC, C#, PHP, Java etc.

Relevant Reading