System.Net.Mail.SmtpException:发送邮件失败 - SMTP 问题

System.Net.Mail.SmtpException: Failure sending mail - SMTP issue

情景 1: 通过使用适当的主机(telnet 在端口 25 上正常工作)在现场提交电子邮件表单来发送邮件在我们的本地系统(代码完全相同)上工作正常,发送次数与我们发送的次数一样多(无论连续提交之间的时间间隔如何) .我们在提交表单时会在上述电子邮件地址中收到回复。

情景 2: 但是当我们在服务器上提交表单时,它第一次成功发送邮件,我们将响应返回到使用的邮件地址。 当我们第二次尝试提交表单时,如果在 2 分 30 秒的间隔(已验证但不确定配置位置)之前尝试,则失败,如果我们在 2 分 30 秒后尝试提交表单,则成功秒

在服务器上,这是我们得到的日志:

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: 
Unable to connect to the remote server ---> System.Net.Sockets.SocketException: 

  A connection attempt failed because the connected party did not 
  properly respond after a period of time, or established connection 
  failed because connected host has failed to respond <SMTP server IP>:25

at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress 
socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, 
IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean 
async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate 
asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate 
asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---

谁能解释一下哪里出了问题?

非常感谢!

好的,关键是: 我的实例托管在 AWS 中,Amazon Elastic Compute Cloud (Amazon EC2) 默认限制端口 25 上的电子邮件流量。

为避免从 EC2 通过 SMTP 端点发送电子邮件时超时,请使用不同的端口(587 或 2587)。否则我们需要向亚马逊填写请求以移除电子邮件发送限制以移除限制。

更多信息位于:https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-connect.html