Amazon SES をセットアップしましたが、最初は数時間動作しましたが、突然停止しました。私が送信しているすべての電子メールと私たちのドメインは確認済みです。大量の電子メールを送信することはありません。1 日に数百通のみです。web.config に変更を加えるたびに、さらに 2 ~ 3 時間は再び機能するようです。たとえば、動作を停止したため、ポート 587 を 25 に切り替えたところ、2 ~ 3 時間動作し始め、その後停止しました。その後、587 に戻しましたが、同じことが起こりました。動作が停止すると、それ自体で再び開始することはないようです。2 つの負荷分散サーバー、asp.net フレームワーク v2.0、IIS 7.5 で実行されています。私が使用しているコードは次のとおりです。
web.config:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="no-reply@ourdomain.com">
<network defaultCredentials="false" host="email-smtp.us-east-1.amazonaws.com" userName="***" password="***" port="587" />
</smtp>
</mailSettings>
</system.net>
c# コード:
var smtpClient = new SmtpClient() { EnableSsl = true };
var mailMessage =
new MailMessage(fromAddress, toAddress, subject, body)
{
IsBodyHtml = true
};
smtpClient.Send(mailMessage);
私が受け取った2つのエラーは次のとおりです。
The following exception was thrown by the web event provider '(null)' in the application '/' (in an application lifetime a maximum of one exception will be logged per provider instance):
System.Web.HttpException: Unable to send out an e-mail to the SMTP server. Please ensure that the server specified in the <smtpMail> section is valid. ---> System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
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.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
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.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at System.Web.Management.MailWebEventProvider.SendMail(MailMessage msg)
--- End of inner exception stack trace ---
at System.Web.Management.MailWebEventProvider.SendMail(MailMessage msg)
at System.Web.Management.SimpleMailWebEventProvider.SendMessageInternal(WebBaseEventCollection events, Int32 notificationSequence, Int32 begin, DateTime lastFlush, Int32 discardedSinceLastFlush, Int32 eventsInBuffer, Int32 messageSequence, Int32 messagesInNotification, Int32 eventsInNotification, Int32 eventsLostDueToMessageLimit)
at System.Web.Management.SimpleMailWebEventProvider.SendMessage(WebBaseEvent eventRaised)
at *****.Global.SimpleMailWithSslWebEventProvider.ProcessEvent(WebBaseEvent raisedEvent)
at System.Web.Management.WebBaseEvent.RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, Int32 index0, Int32 index1)
The following exception was thrown by the web event provider '(null)' in the application '/' (in an application lifetime a maximum of one exception will be logged per provider instance):
System.Web.HttpException: Unable to send out an e-mail to the SMTP server. Please ensure that the server specified in the <smtpMail> section is valid. ---> System.Net.Mail.SmtpException: Service not available, closing transmission channel. The server response was: Timeout waiting for data from client.
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at System.Web.Management.MailWebEventProvider.SendMail(MailMessage msg)
--- End of inner exception stack trace ---
at System.Web.Management.MailWebEventProvider.SendMail(MailMessage msg)
at System.Web.Management.SimpleMailWebEventProvider.SendMessageInternal(WebBaseEventCollection events, Int32 notificationSequence, Int32 begin, DateTime lastFlush, Int32 discardedSinceLastFlush, Int32 eventsInBuffer, Int32 messageSequence, Int32 messagesInNotification, Int32 eventsInNotification, Int32 eventsLostDueToMessageLimit)
at System.Web.Management.SimpleMailWebEventProvider.SendMessage(WebBaseEvent eventRaised)
at *****.Global.SimpleMailWithSslWebEventProvider.ProcessEvent(WebBaseEvent raisedEvent)
at System.Web.Management.WebBaseEvent.RaiseInternal(WebBaseEvent eventRaised, ArrayList firingRuleInfos, Int32 index0, Int32 index1)
Amazon フォーラムで助けを求めようとしましたが、うまくいきませんでした。何かが接続を妨害しているように見えますが、何が原因かわかりません。何か案は?ありがとう。