Error for mail triggering:System.Net.Mail.SmtpException: 'The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; the Client was not authenticated to send anonymous mail during MAIL FROM'
Code :
using (SmtpClient smtp = new SmtpClient())
{
smtp.Port = _configuration.GetValue<int>(Constants.EmailServer + Constants.Port);
smtp.Host = _configuration.GetValue<string>(Constants.EmailServer+Constants.SmtpHost);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
await smtp.SendMailAsync(message);
}
values are set in appsettings.json