I use below code to mail config .thats works in other applications but my application shows the below error how to fix it.
Msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = ConfigurationManager.AppSettings["MailServer"];
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
Msg.From = new MailAddress(ConfigurationManager.AppSettings["MailFrom"]);
NetworkCred.Password = ConfigurationManager.AppSettings["MailPassword"];
smtp.Credentials = NetworkCred;
smtp.Port = 25;
smtp.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, System.Security.Cryptography.X509Certificates.X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
};
smtp.Send(Msg);
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