this is the way i'm sending the email
try
{
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress("user@domain.com");
mail.To.Add("example@gmail.com");
mail.Subject = "Hello World";
mail.Body = "<h1>Hello</h1>";
mail.IsBodyHtml = true;
using (System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com", 587))
{
smtp.Credentials = new System.Net.NetworkCredential("user@domain.com", "password");
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Send(mail);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
I did already activate the less secure app in account security setting.
This is the exception error :
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required