the email code works on local host but when i upload the website on server it shows 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
//Formatted
protected void btnSend_Click(object sender, EventArgs e)
{
            var fromAddress = "djdanny1255@gmail.com";
              string email = "djdanny1255@gmail.com";
            var toAddress = email;
            const string fromPassword = "********";
            string subject = "Email=" + txtEmail.Text + "     Phone=" + txtMobile.Text;
            string body = txtMessage.InnerText;
            try
            {
                using (MailMessage mm = new MailMessage(fromAddress, email))
                {
                    mm.Subject = subject;
                    mm.Body = body;
                    mm.IsBodyHtml = false;
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    smtp.EnableSsl = true;
                    NetworkCredential NetworkCred = new NetworkCredential(fromAddress, fromPassword);
                    smtp.UseDefaultCredentials = true;
                    smtp.Credentials = NetworkCred;
                    smtp.Port = 587;
                    smtp.Send(mm);
                }
            }
            catch (Exception ex)
            {
                Response.Write("Error" + ex.Message);
            }
 
     
    
