Windows Server2008:打开smtp端口不足以发送邮件吗?

发布于 2024-11-10 11:00:39 字数 1100 浏览 5 评论 0 原文

我用 C# 编写了一个发送邮件通知的简单程序。它在 Windows 7 上工作得很好,但在 Server 2008 上却失败了。

我读过一些相关内容,但我不明白是什么阻止了我发送邮件。我已经打开端口 587(Gmail 的 SSL 端口)传出和传入 (TCP),但仍然没有运气。我什至为整个程序打开了防火墙。 Windows Server 中是否有我应该注意的特定设置?

*编辑-除了Windows自己的防火墙之外没有其他防火墙。

堆栈跟踪:

System.Net.Mail.SmtpException: Failure sending mail.
---> System.Net.WebException: Unable to connect to the remote server
---> System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full 74.125..:587
     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, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---

编辑:我找到了答案:问题与 Windows 服务器无关。这是因为它无法连接到我的数据库。愚蠢的我。早些时候,当无法连接到数据库时,我收到了连接错误,但现在我收到的只是奇怪的错误消息;其中一篇已发布在这里。

无论如何,感谢所有帮助!这么快就得到帮助真是太好了。

I have written a simple program in C# that sends mail notifications. It works great on Windows 7, but it fails on Server 2008.

I've read a bit about it, but I can't see what is keeping me from sending mail. I've opened port 587 (SSL port for Gmail) outgoing and ingoing (TCP) but still no luck. I even opened the firewall for the whole program. Are there specific settings in Windows Server that I should be aware of?

*Edit - No other firewalls than windows' own.

Stack trace:

System.Net.Mail.SmtpException: Failure sending mail.
---> System.Net.WebException: Unable to connect to the remote server
---> System.Net.Sockets.SocketException: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full 74.125..:587
     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, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---

EDIT: I found my answer: The problem was nothing to do with windows server. It was because it could not connect to my database. Silly me. Earlier i got a connection error when not able to connect to database, but now all i got was weird error messages; one of which was posted here.

Thanks for all help anyways! Great to get help so quickly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

望她远 2024-11-17 11:00:39

线索就在例外中,我怀疑与您的防火墙有什么关系:

System.Net.Sockets.SocketException: An operation on a socket could not be performed 
because the system lacked sufficient buffer space or because a queue was full

有一篇 Microsoft 知识库文章可能值得回顾,它适用于 Windows 2003,但我仍然会调查它:

BUG:访问 Web 服务时收到“操作已超时”错误消息或者当您使用 IPAddress 类时

根据这篇文章,该问题似乎也可能发生在 Windows 2008 下,尽管该文章是关于 Windows EBS 的,但根本原因似乎是相同的(向右滚动到该文章的底部) 页):

EBS 控制台每 5-7 天崩溃一次

基本上 Windows 可能会耗尽协议绑定。他们描述了一个名为 enum.exe 的工具,该工具将确定您的计算机上存在的协议绑定的数量。

Stack Overflow 上有一篇相关文章:

为什么我在 C# 中收到此 SocketException服务?

The clue is in the exception and I doubt has anything to do with your firewall:

System.Net.Sockets.SocketException: An operation on a socket could not be performed 
because the system lacked sufficient buffer space or because a queue was full

There is a Microsoft KB article that may be worth reviewing, it's for Windows 2003 but I'd investigate it all the same:

BUG: You receive a "The operation has timed-out" error message when you access a Web service or when you use the IPAddress class

It also looks like the issue can occur under Windows 2008 as well according to this article which although is about Windows EBS, the underlying cause appears to be the same (scroll right to the bottom of the page):

EBS Console crashes every 5-7 days

Basically it's possible for windows to run out of protocol bindings. They describe a tool called enum.exe that will determine the number of protocol bindings present on your machine.

There is a related article on Stack Overflow here:

Why am I getting this SocketException in my C# service?

公布 2024-11-17 11:00:39

提供的异常信息是否有可能为您提供有关问题所在的线索?那是:

无法对套接字进行操作
因为系统缺少执行
足够的缓冲空间或因为
队列已满 74.125..:587

请参阅 http://blogs.msdn.com/b/sql_protocols/archive/2009/03/09/understanding-the-error-an-operation-on-a-socket-could-not-be-执行是因为系统缺乏足够的缓冲区空间或因为队列已满.aspx

在 .NET 中,这很可能是由于未处理 SmtpClient 造成的。

Is it possible that the exception information provided will give you a clue as to what's wrong? That is:

An operation on a socket could not be
performed because the system lacked
sufficient buffer space or because a
queue was full 74.125..:587

See http://blogs.msdn.com/b/sql_protocols/archive/2009/03/09/understanding-the-error-an-operation-on-a-socket-could-not-be-performed-because-the-system-lacked-sufficient-buffer-space-or-because-a-queue-was-full.aspx.

In .NET, it's quite possible that this would be caused by not disposing of your SmtpClient.

弥繁 2024-11-17 11:00:39

首先尝试排除故障,因为问题可能出在其他地方:-)

  1. 尝试禁用防火墙并尝试一下。这可能与 Windows 2008 上的防火墙完全不同,阻止您
  2. 尝试运行您尝试访问的 telnet yourSmtpServer 587

Try troubleshooting things first as problem may be somewhere else :-)

  1. Try disabling firewall and give it a go. It may be something really different then firewall on Windows 2008 blocking your way
  2. Try running telnet yourSmtpServer 587 that you are trying to reach
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文