4

我正在使用 amazon ses 发送电子邮件,并且在网站和 Windows 应用程序中使用相同的配置。
该网站正在正常发送电子邮件,但 Windows 应用程序给了我这个错误,而不是发送的电子邮件:在此处输入图像描述

请注意,当我将 windows 应用程序中的 smtp 配置更改为 gmail 之类的东西时,它工作正常,问题发生在亚马逊 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"}
4

3 回答 3

4

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

添加

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

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

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

于 2013-07-25T13:11:16.133 回答
0

看看这个 SO 帖子,从网上阅读很多人指出证书是问题所在,我想知道您使用的“验证”文件是否实际上是错误的;他们通过用 .p12 替换“.pem 文件”解决了这个问题

还要看看这个听起来很像你的问题的MS 修补程序。

也正如 FeliceM 所暗示的,这可能是一个帐户问题:(取自)

" Aspnet 在不同的帐户下运行,因此您必须使用 WinHttpCertCfg.exe 工具来允许以下帐户访问您应该安装在本地计算机个人/受信任文件夹中的证书。

ASPNET 网络服务认证用户

例如

winhttpcertcfg -g -c LOCAL_MACHINE\MY -s "CertificateName" -a "ASPNET"

其中证书名称是您的证书的友好名称。

您可以从以下链接获取工具和信息:

http://msdn.microsoft.com/en-us/library/aa384088%28VS.85%29.aspx#%5Fusing

"

于 2013-05-09T09:55:36.407 回答
0

尝试检查您的 SPN (ServicePrincipalName) 配置。这个问题听起来像是在您的配置中某处发生了损坏或修改。如果服务实例的登录帐户发生变化,则必须在新帐户下重新注册 SPN。

于 2013-05-08T07:02:16.073 回答