gpt4 book ai didi

c# - 从 Windows 应用程序使用 amazon ses 发送电子邮件时调用 SSPI 失败

转载 作者:行者123 更新时间:2023-11-30 16:18:33 26 4
gpt4 key购买 nike

我正在使用 amazon ses 发送电子邮件,并且我在网站和 Windows 应用程序中使用相同的配置。
该网站正常发送电子邮件,但 Windows 应用程序给我这个错误,而不是发送的电子邮件:enter image description here

请注意,当我将 windows 应用程序中的 smtp 配置更改为 gmail 之类的东西时,它工作正常,问题只发生在 amazon ses 上,直到今天才开始发生,在此之前 ses 在 windows 应用程序上运行良好。
另请注意,网站和 Windows 应用程序现在都可以在本地运行。

堆栈跟踪:

   at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.TlsStream.CallProcessAuthentication(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Mail.SmtpConnection.Flush()
at System.Net.Mail.ReadLinesCommand.Send(SmtpConnection conn)
at System.Net.Mail.EHelloCommand.Send(SmtpConnection conn, String domain)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Mail.EmailSender.SendMail(MailMessage mail) in e:\Mail\EmailSender.cs:line 175

内部异常:

{"The message received was unexpected or badly formatted"}

最佳答案

我遇到了同样的问题,最终归结为尝试连接时生效的 SecurityProtocol。

添加

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

在 client.Send 为我解决之前(我们在其他地方将其更改为 Ssl3 以与不同的服务对话)如果 .Net 团队中的任何人正在阅读,如果这(和 ServerCertificateValidationCallback)不是全局的,那就太好了.

我不知道这是 SES 的“功能”还是我只是假设魔术应该起作用,但您可以在此处查看一些历史记录: https://forums.aws.amazon.com/thread.jspa?messageID=472516

关于c# - 从 Windows 应用程序使用 amazon ses 发送电子邮件时调用 SSPI 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16071766/

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