gpt4 book ai didi

c# - Azure 函数 : Client was not authenticated to send anonymous mail during MAIL FROM [DB6P189CA0021. EURP189.PROD.OUTLOOK.COM]

转载 作者:行者123 更新时间:2023-12-03 04:19:09 25 4
gpt4 key购买 nike

我想在 Azure Function 中发送电子邮件。我写下下面的代码。 它在控制台应用程序中正常工作并且我能够使用凭据发送电子邮件。但是当我在 Azure Function 中测试相同的代码时,它抛出了以下错误。

Exception while executing function: Functions.HttpTriggerCSharp. Microsoft.Azure.WebJobs.Script: One or more errors occurred. f-HttpTriggerCSharp__-1774598883: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [DB6P189CA0021.EURP189.PROD.OUTLOOK.COM]

我使用的代码 -

 SmtpClient client = new SmtpClient("smtp-mail.outlook.com");
string _sender = "--email--";
string _password = "-password---";
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential(_sender, _password);
client.EnableSsl = true;
client.Credentials = credentials;
string recipient = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5974742d3c2a2d19362c2d35363632773a36347474" rel="noreferrer noopener nofollow">[email protected]</a>";
string subject="Temperature of device exceeds";
string message="Temperature of device exceeds";
try
{
var mail = new MailMessage(_sender.Trim(), recipient.Trim());
mail.Subject = subject;
mail.Body = message;
client.Send(mail);
}
catch (Exception ex)
{

}

最佳答案

我使用队列触发器并在我的 azure 函数(v1)中遵循您的代码,效果很好。

The server response was: 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM

此消息表明您的外发邮件帐户中配置的 SMTP 服务器正在连接到无法用于直接发送的 SMTP 客户端提交端点。

将您的 Exchange SMTP 配置为直接发送。

配置电子邮件通知在DS-Client >设置>配置>通知中选择SMTP,添加SMTP服务器设置并选择添加SMTP服务器设置服务器需要身份验证。

在SMTP服务器验证窗口中添加office365验证的帐户信息。

有关详细信息,请参阅以下 Microsoft 文章:

Fix issues with printers, scanners, and LOB applications that send email using Office 365

How to set up a multifunction device or application to send email using Office 365

关于c# - Azure 函数 : Client was not authenticated to send anonymous mail during MAIL FROM [DB6P189CA0021. EURP189.PROD.OUTLOOK.COM],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50623880/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com