2011-05-30 26 views
3

我已经用C#编写了一个简单的程序来发送邮件通知。它在Windows 7上运行良好,但在Server 2008上运行良好。Windows Server2008:打开smtp端口不够发送邮件?

我已经阅读了一些内容,但看不到什么让我无法发送邮件。我已经打开了端口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服务器。这是因为它无法连接到我的数据库。傻我。之前当无法连接到数据库时,出现连接错误,但现在我只能看到奇怪的错误消息;其中之一张贴在这里。

感谢您的帮助!很高兴得到如此迅速的帮助。第一

+0

根据[其常见问题](http://mail.google.com/support/bin/answer.py?answer=13287),gmail的SMTP SSL端口是'465'('587'是TLS端口) 。也许这就是问题所在? – 2011-05-30 10:48:24

+0

由于您将程序作为*普通*应用程序运行,或者作为服务运行? – Oliver 2011-05-30 11:58:15

+0

尝试发送时是否收到代码错误?如果是这样,你可以包含堆栈跟踪吗? – 2011-05-30 20:59:44

回答

0

尝试排除故障事情,问题可能是别的地方:-)

  1. 尝试禁用防火墙,并给它一展身手。这可能是一些真正不同的,那么在Windows 2008防火墙挡住你的路
  2. 尝试运行telnet yourSmtpServer 587您试图达到
2

线索是例外,我怀疑有什么用你的防火墙:

 
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 

有一个微软知识库文章,可能是值得检讨,这是为Windows 2003,但我会调查这一切一样:

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

它也像这个问题,以及根据这篇文章里面虽然是有关Windows EBS在Windows 2008下可以发生,根本原因似乎是相同的(向右滚动到页面的底部) :

EBS Console crashes every 5-7 days

基本上它是一个可能的窗口用完协议绑定。他们描述了一个名为enum.exe的工具,它将确定您机器上存在的协议绑定的数量。

有堆栈溢出这里相关文章:

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

1

是否有可能提供的异常信息会给你一个线索,有什么不对?那就是:不能 进行

套接字上的操作,因为系统缺少 足够的缓冲空间,或因为 队列已满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-performed-because-the-system-lacked-sufficient-buffer-space-or-because-a-queue-was-full.aspx

在.NET中,这很有可能是由于不处置您的SmtpClient引起的。