2011-05-30 27 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引起的。