[英]System.Net.Sockets.SocketException
Encoding en = Encoding.GetEncoding("iso-8859-1"); // default encoding
IPHostEntry IPhst = Dns.GetHostEntry(_Host);
IPEndPoint endPt = new IPEndPoint(IPhst.AddressList[0], 25);
Socket s = new Socket(endPt.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
s.Connect(endPt);
Here am getting the error like:这里出现如下错误:
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 202.88.253.162:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)"
System.Net.Sockets.SocketException:连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接的主机未能响应 202.88.253.162:25 在 System.Net.Sockets.Socket 建立连接失败.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)"
How i can solve this?我怎么能解决这个问题?
The is no server listening at specified ip/port that you are trying to connect to.没有服务器在您尝试连接的指定 ip/端口进行侦听。
Possible causes for the error:错误的可能原因:
Update更新
Didn't see that you are trying to connect to a SMTP server.没有看到您正在尝试连接到 SMTP 服务器。 Many ISP:s block port 25 for all ip addresses except their own SMTP servers.
许多 ISP:s 阻止所有 ip 地址的端口 25,除了他们自己的 SMTP 服务器。 It's to reduce SPAM emails.
这是为了减少垃圾邮件。 So that could be the cause too.
所以这也可能是原因。
Try using the IP 127.0.0.1.尝试使用 IP 127.0.0.1。 It might work.
它可能会起作用。
I changed port 25 to 587 in my code.我在代码中将端口 25 更改为 587。
SmtpServer.Port = 587;
And it stared working =)它开始工作了=)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.