title: how to send email in Asp.net mvc 5
body: <p>What code should I use to send email in C#?</p>
  
  <p>I tried to find a specific code so that I could send an email from my website.
  And then I get an 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"</p>
  
  <pre><code>public void sendEmail(string toEmail, string subject, string emailBody)
  {
       string senderEmail = "My_Email";
       string senderPassword = "My_Email_Password";
       SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
       client.EnableSsl = true;
       client.Timeout = 500000;
       client.DeliveryMethod = SmtpDeliveryMethod.Network;
       client.UseDefaultCredentials = false;
       client.Credentials = new NetworkCredential(senderEmail, senderPassword);
       MailMessage mailMessage = new MailMessage(senderEmail, toEmail, subject, emailBody);
       mailMessage.IsBodyHtml = true;
       mailMessage.BodyEncoding = UTF8Encoding.UTF8;
       client.Send(mailMessage);
  }
  </code></pre>
  
  <p>Do I need to use Google API??</p>