WebException中的SmtpException:无法连接到远程服务器

时间:2011-11-15 10:04:45

标签: smtpclient socketexception system.net.webexception

我正在尝试使用smtp服务器发送邮件,但我收到了以下异常。 请给我一些建议..

  

System.Net.Mail.SmtpException:发送邮件失败。
  ---> System.Net.WebException:无法连接到远程服务器
  ---> System.Net.Sockets.SocketException:尝试对无法访问的网络进行套接字操作184.xx.xxx.xx:25
   在System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,SocketAddress socketAddress)
   在System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,Socket s4,Socket s6,Socket& socket,IPAddress& address,ConnectSocketState state,IAsyncResult asyncResult,Int32 timeout,Exception& exception)
   ---内部异常堆栈跟踪结束---
   在System.Net.ServicePoint.GetConnection(PooledStream PooledStream,Object owner,Boolean async,IPAddress& address,Socket& abortSocket,Socket& abortSocket 6,Int32 timeout)
   在System.Net.PooledStream.Activate(对象拥有对象,布尔异步,Int32超时,GeneralAsyncDelegate asyncCallback)
   在System.Net.PooledStream.Activate(Object owningObject,GeneralAsyncDelegate asyncCallback)
   在System.Net.ConnectionPool.GetConnection(对象拥有对象,GeneralAsyncD elegate asyncCallback,Int32 creationTimeout)
   在System.Net.Mail.SmtpConnection.GetConnection(String host,Int32 port)
   在System.Net.Mail.SmtpTransport.GetConnection(String host,Int32 port)
   在System.Net.Mail.SmtpClient.GetConnection()
   在System.Net.Mail.SmtpClient.Send(MailMessage消息)
   ---内部异常堆栈跟踪结束---
   在E:\ testEmail \ testEmail \ Module1.vb中的testEmail.Module1.Main()的System.Net.Mail.SmtpClient.Send(MailMessage消息):第17行

2 个答案:

答案 0 :(得分:0)

该消息告诉我您的网络服务器连接到您的SMTP服务器时出现问题。你确定SMTP地址是对的吗?

请记住,某些SMTP服务器需要登录

如果您使用不同的IPS

,某些SMTP服务器也不允许您连接

我会将SMTP更改为您的ISP所具有的SMTP。 您可以尝试使用Telnet连接到SMTP以检查连接

telnet YourSmtpAddress 25

答案 1 :(得分:0)

从这个消息来看

尝试对无法访问的网络进行套接字操作184.xx.xxx.xx:25

您似乎无法访问SMTP地址。

检查您的互联网连接,然后检查地址是否正确。 如果地址正确,Ping到地址或tracerout可以帮助您理解无法联系服务器的原因