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
var fromAddres
Below is my code.I also had the same error but the problem was that i gave my password wrong.The below code will work perfectly..try it
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("fromaddress@gmail.com");
mail.To.Add("toaddress1@gmail.com");
mail.To.Add("toaddress2@gmail.com");
mail.Subject = "Password Recovery ";
mail.Body += " ";
mail.Body += "";
mail.Body += "";
mail.Body += "";
mail.Body += "User Name : HAi ";
mail.Body += " ";
mail.Body += "";
mail.Body += "Password : aaaaaaaaaa ";
mail.Body += " ";
mail.Body += "
";
mail.Body += "";
mail.Body += "";
mail.IsBodyHtml = true;
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("sendfrommailaddress.com", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
You can refer it in my blog