gpt4 book ai didi

c# - SMTP 电子邮件发送中的问题,Azure 中托管的 ASP .Net mvc 应用程序

转载 作者:行者123 更新时间:2023-12-03 00:39:16 24 4
gpt4 key购买 nike

我是 azure 的新手。我的 asp .net MVC 应用程序托管在 azure 中。该应用程序具有电子邮件发送功能。当应用程序迁移到 azure 时,电子邮件功能无法运行。我的错误日志显示错误如下:

System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. a65sm9218660oih.6 - gsmtp
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)

用于发送电子邮件的代码块

SmtpClient client = new SmtpClient(GetStringValue(EMAIL_CLIENT), GetIntValue(EMAIL_PORT))
{
Credentials = new NetworkCredential(GetStringValue(EMAIL_USER_NAME), GetStringValue(EMAIL_PASSWORD)),
EnableSsl = sslOn
};

client.Host = SettingsManager.GetStringValue("EmailClient");//smtp.gmail.com
client.Port = SettingsManager.GetIntValue("EmailPort");//587
client.DeliveryMethod = SmtpDeliveryMethod.Network;

谁能帮我解决这个问题。谢谢。

最佳答案

即使我在使用 gmail 时也遇到了同样的问题。 Gmail 会阻止您通过 azure 发送的电子邮件,因为您的应用正在尝试从时区不同或与您用于创建帐户的位置不同的位置登录。检查您的 Gmail 收件箱,其中将包含一封有关阻止登录尝试的电子邮件。

The solution is to either login to gmail from your azure server or check the blocked email in your inbox and add that device to verfied devices. ie select "I recognize this activity as mine" as mentioned in this link.

关于c# - SMTP 电子邮件发送中的问题,Azure 中托管的 ASP .Net mvc 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41217380/

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