F# 应用程序 Gmail 身份验证问题

时间:2021-03-05 02:16:08

标签: .net-core f# gmail email-client

2021.03.05 更新: .net 4.8(应用程序或fsi)似乎不会发生这种情况 但总是发生在 .net 5.0(应用程序和 fsi)

https://github.com/ingted/dotnet5mail

很奇怪,如果我使用 .net4.8 执行此代码,电子邮件会成功发送,但不会使用 .net 5.0。 (它会说“未处理的异常。System.AggregateException:发生一个或多个错误。(SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应为:5.7.0 需要身份验证。”)

  1. 我已经使用了此处提到的应用密码Sign in with App Passwords
  2. 我只使用纯 .net 库

enter image description here

1 个答案:

答案 0 :(得分:1)

System.Net.Mail.SmtpClient() 在 .NET 5 中已过时。

SmtpClient 已经过时,因为我相信 .NET Core 2.0 和 .NET 5 更接近于 .NET Core 3.1 的进步,而不是 .NET Framework 4.8 的进步。

<块引用>

参考:https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient?view=net-5.0

Microsoft 建议改用 MailKit。

Nuget 链接

<块引用>

https://www.nuget.org/packages/MailKit/