我有一个在 ASP.NET 4.0 框架上用 VB 编写的(长时间)运行的 web 应用程序。
我们一直在使用 SparkPost 发送电子邮件,但几天后(不确定确切日期),电子邮件功能已停止工作并开始给出以下错误消息
身份验证失败,因为远程方已关闭传输流。
我们使用MailKit版本 1.22(最新支持 ASP.NET 4.0)建立连接并发送电子邮件,如下所示:
Using objMessage As New MailMessage(from, to, title, message)
objMessage.IsBodyHtml = True
'https://github.com/jstedfast/MailKit
Using client As New MailKit.Net.Smtp.SmtpClient()
''accept all SSL certificates (in case the server supports STARTTLS)
client.ServerCertificateValidationCallback = Function(sender, certificate, chain, errors)
Return True
End Function
''Note: since we don't have an OAuth2 token, disable the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2")
client.AuthenticationMechanisms.Add("AUTH LOGIN")
client.Connect("smtp.sparkpostmail.com", 587, SecureSocketOptions.StartTls)
''Note: only needed if the SMTP server requires authentication
client.Authenticate("SMTP_Injection", "**********************")//the asterixes are the API key
client.Send(objMessage)
client.Disconnect(True)
End Using
End Using
这个带有 StartTLS 的设置是 SparkPost 文档希望我使用的。
我读到 SparkPost 最近停止支持 TSL 1.0。这可能是罪魁祸首吗?