开发者

Windows Server2008: Is opening smtp port not enough for sending mail?

开发者 https://www.devze.com 2023-03-09 00:36 出处:网络
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 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 no开发者_开发技巧thing 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.


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?


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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号