就像我尝试向客户发送电子邮件一样,它出现并表示存在问题。
它说的问题是:
错误:
SmtpException:邮箱不可用。服务器响应是:不允许未经身份验证的发件人
问题可能是我没有写过内容而不是用某些方法调用它们吗?
或者然而,我认为问题出在SmtpClient
区域。
代码:
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.