【问题标题】:C# Mail Sending Error in smtp.office365.com SMTP Serversmtp.office365.com SMTP 服务器中的 C# 邮件发送错误
【发布时间】:2021-08-02 18:56:20
【问题描述】:

我正在使用以下代码进行 SMTP 配置。

SmtpClient smtp = new SmtpClient
{
    Host = data.SMTPServer, // smtp server address here...
    Port = data.PortNo,
    EnableSsl = data.SSL,
    DeliveryMethod = SmtpDeliveryMethod.Network,
    UseDefaultCredentials = false,
    Credentials = new System.Net.NetworkCredential(senderID, senderPassword),
    Timeout = 30000,
};
smtp.Send(message);

一个客户端配置了 SMTP 服务器 - smtp.office365.com。

SMTP 服务器返回错误 - 没有 SSL:-

Error in processing. The server response was: 5.7.3 STARTTLS is required to send mail [XXX.XXX.PROD.OUTLOOK.COM]

使用 SSL:-

The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 Client not authenticated to send mail. [XXXX.XXXX.PROD.OUTLOOK.COM]

上面的 SMTP 代码非常适合其他客户端。 有什么意见需要做些什么来解决这个问题?

【问题讨论】:

  • 这是否为您解决了?我面临同样的问题。如果你解决了,你能在这里更新吗?
  • @SanketPatel 尚未确定。我的代码还是一样的。从 SMTP 服务器端看这个问题更多。

标签: c# asp.net email smtp office365


【解决方案1】:

确保以下几点正确:

  • 凭据正确
  • 使用正确的端口号(587 或 25)
  • 应用程序必须能够使用 TLS 1.2 或更高版本(您可以通过在调用服务之前添加以下代码来测试这一点:System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-09
    • 2019-05-11
    • 1970-01-01
    • 2022-11-08
    相关资源
    最近更新 更多