You could try authentification via “App password”.
On your Google account:
-
set 2-Step Verification ON
-
create 16-character “App password”(
How to create app password) -> result should be similar to:
16-character “App password” -
Instead of Google account password use 16-character password
MailMessage mail = new MailMessage(); foreach (string receiver in DolociPrejemnike()) mail.To.Add(receiver); mail.From = new MailAddress("[email protected]", "No replay"); //pošiljatelj (vedno enak) mail.Subject = SetSubject(); mail.Body = SetBody(); mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.Port = 587; smtp.UseDefaultCredentials = true; smtp.Credentials = new System.Net.NetworkCredential("[email protected]", "xtqapucsmyvqmvxp"); // Enter seders User name and password smtp.EnableSsl = true; smtp.Send(mail);