我正在尝试为asp.net项目设置电子邮件通知,但它似乎无法正常工作。在localhost上它给我以下错误
5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
在azure上,它会一遍又一遍地触发可疑的登录信息。 我尝试了多个建议:
var client = new SmtpClient();
client.Host = "smtp.office365.com";
client.UseDefaultCredentials = false;
client.Port = 587;
client.EnableSsl = true;
client.Credentials = new NetworkCredential("Rachelle.XXXX@outlook.com", "password");
client.DeliveryMethod = SmtpDeliveryMethod.Network;
var message = new MailMessage("Rachelle.XXXX@outlook.com", "Rachelle_xxxxx@hotmail.com");
message.Subject = "a ticket has been changed";
message.Body = "Hi there, a ticket has been changed on Cronos. Please check Cronos for more details";
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
try
{
client.Send(message);
return message;
}