1

It's like when I try to send email to customers, it comes forward and says there's a problem.

The problem that it says is:

Error:

SmtpException: Mailbox unavailable. The server response was: Unauthenticated senders not allowed

Could the problem be that I have not written content instead of calling them on some methods?

or However, I think that the problem lies in the SmtpClient area.

Code:

var viewModel = new EmailModel{
    Title = title,
    FullName = UserValue.Navn,
    Password = randomPassworduser
};
var m = new Settings();
var resultMail = await _viewRenderService.RenderToStringAsync("~/Views/Templates/NewPassword.cshtml", viewModel);
var mailMessage = new MailMessage{
    From = new MailAddress(m.mailFrom(), m.nameFrom()),
    Subject = title,
    Body = Regex.Replace(resultMail, "<[^>]*>", ""),
    IsBodyHtml = false
};
mailMessage.To.Add(new MailAddress(UserValue.Mail));
var smtpClient = new SmtpClient{
    Credentials = new NetworkCredential(m.azureName(), m.password()),
    Host = m.host(),
    Port = m.port(),
    UseDefaultCredentials = false
};
await smtpClient.SendMailAsync(mailMessage);
return RedirectToAction("UserPassword");//error say here.
GYaN
  • 2,327
  • 4
  • 19
  • 39

0 Answers0