title: Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
body: <p>I am using following code to send email. The Code works correctly in my local Machine. But on Production server i am getting the error message</p>
  
  <pre><code>var fromAddress = new MailAddress("mymailid@gmail.com");
  var fromPassword = "xxxxxx";
  var toAddress = new MailAddress("yourmailid@yourdoamain.com");
  
  string subject = "subject";
  string body = "body";
  
  System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient
  {
      Host = "smtp.gmail.com",
      Port = 587,
      EnableSsl = true,
      DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network,
      UseDefaultCredentials = false,
      Credentials = new NetworkCredential(fromAddress.Address, fromPassword)       
  };
  
  using (var message = new MailMessage(fromAddress, toAddress)
  {
      Subject = subject,
      Body = body
  })
  
  smtp.Send(message);
  </code></pre>
  
  <p>And on my Gmail A/c I have received the following email after i ran the code from production server</p>
  
  <blockquote>
    <p>Hi , </p>
    
    <p>Someone recently used your password to try to sign in to your Google
    Account mymailid@gmail.com. This person was using an application such
    as an email, client or mobile device. </p>
    
    <p>We prevented the sign-in attempt in case this was a hijacker trying to
    access your account. Please review the details of the sign-in attempt:</p>
    
    <p>Friday, 3 January 2014 13:56:08 o'clock UTC  IP Address: xxx.xx.xx.xxx
    (abcd.net.)  Location: Philadelphia PA, Philadelphia, PA, USA</p>
    
    <p>If you do not recognise this sign-in attempt, someone else might be
    trying to access your account. You should sign in to your account and
    reset your password immediately. </p>
    
    <p>Reset password  </p>
    
    <p>If this was you and you are having trouble accessing your account,
    complete the troubleshooting steps listed at
    <a href="http://support.google.com/mail?p=client_login" rel="noreferrer">http://support.google.com/mail?p=client_login</a> </p>
    
    <p>Yours sincerely, The Google Accounts team</p>
  </blockquote>