I know this question has been posted many times before, and I have tried the solutions from the existing posts but with no success, and by solutions I mean changing the password from the GMail account to a stronger one and turning on access for less secure apps. The error message that I still get is:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
I understand from this that the gmail server will not authenticate the account.
The code for the app is as follows:
private void button1_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To.Add("mail@domain.com");
mail.From = new MailAddress("xxx@gmail.com");
mail.Subject = textBox3.Text;
string Body = richTextBox1.Text;
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("xxx@gmail.com", "xxxxxxx");// Enter seders User name and password
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mail);
}
Any help would be much appreciated as I am facing the problem for 2 days now.