The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at
Less secure app access: ON in google
using (MailMessage emailMessage = new MailMessage()) { emailMessage.From = new MailAddress(_mailConfig.Value.FromEmail, _mailConfig.Value.FromName); emailMessage.To.Add(new MailAddress(to)); emailMessage.Subject = subject; emailMessage.Body = emailBody; emailMessage.IsBodyHtml = true; emailMessage.BodyEncoding = Encoding.UTF8; emailMessage.Priority = MailPriority.Normal; using (SmtpClient MailClient = new SmtpClient("smtp.gmail.com", 587)) { MailClient.UseDefaultCredentials = false; MailClient.EnableSsl = true; MailClient.Credentials = new System.Net.NetworkCredential("test@gmail.com", "password"); MailClient.Send(emailMessage); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)