C#:SMTP 错误

发布于 2024-12-27 10:41:00 字数 727 浏览 2 评论 0原文

我正在创建一个电子邮件客户端,它从服务器 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦过后 2025-01-03 10:41:00

我认为“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.

甜尕妞 2025-01-03 10:41:00

根据此 SMTP 服务器测试 服务器未打开在端口 25 上接收连接:

无法建立连接,因为目标机器主动拒绝50.23.128.66:25

服务器可能使用某种形式的加密,并且您必须连接到“安全”SMTP 端口之一。

您确定它是 SMTP 服务器,而不是 IMAP 服务器或类似服务器吗?

According to this SMTP Server Test the server is not open to receiving connections on port 25:

No connection could be made because the target machine actively refused it 50.23.128.66: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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文