C#:SMTP 错误
我正在创建一个电子邮件客户端,它从服务器 ip 而不是 SMTP 发送电子邮件地址,我编写了以下代码:
SmtpClient server = new SmtpClient();
server.Host= "50.23.128.66";
server.Port = 25;
server.Send("[email protected]", "[email protected]", "hi", "hope it works");
但是当我运行它时,我收到该错误:
未处理的异常:System.Net.Mail.SmtpException:服务不 可用,关闭传输通道。服务器响应是: 无法连接到 SMTP 服务器 50.23.128.66 (50.23.128.66:25),连接错误10061
我实际上认为端口错误。 * 顺便说一下,我使用的是 Windows Server 2008 *
i am creating an email client that sends e-mail address from server ip instead of SMTP , i wrote the following code:
SmtpClient server = new SmtpClient();
server.Host= "50.23.128.66";
server.Port = 25;
server.Send("[email protected]", "[email protected]", "hi", "hope it works");
but when i run it, i get that error:
Unhandled Exception: System.Net.Mail.SmtpException: Service not
available, closing transmission channel. The server response was:
Cannot connect to SMTP server
50.23.128.66 (50.23.128.66:25), connect error 10061
i actually think that port is wrong . * By the way i am using Windows Server 2008 *
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为“connect error 10061”与 POSIX 平台上的 errno == ECONNREFUSED 相同,这意味着连接未成功,可能是因为您尝试连接的主机没有在端口 25 上运行任何类型的服务器。
I think "connect error 10061" is the same as errno == ECONNREFUSED on a POSIX platform, which means the connection did not succeed, probably because the host you tried to connect to isn't running any sort of server on port 25.
根据此 SMTP 服务器测试 服务器未打开在端口 25 上接收连接:
服务器可能使用某种形式的加密,并且您必须连接到“安全”SMTP 端口之一。
您确定它是 SMTP 服务器,而不是 IMAP 服务器或类似服务器吗?
According to this SMTP Server Test the server is not open to receiving connections on port 25:
It's possible the server uses some form of encryption, and you will have to connect on one of the "secure" SMTP ports.
Are you sure it's an SMTP server, and not an IMAP server or the like?