系统.网邮政SmtpException:发送邮件失败-SMTP问题


场景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 EC2(会抑制端口25上的电子邮件流量。

为了避免从EC2通过SMTP端点发送电子邮件时超时,请使用其他端口(587或2587(。否则,我们需要填写一份"请求亚马逊删除电子邮件发送限制"以删除限制。

更多信息,请访问:https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-connect.html

最新更新