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.
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:
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):
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:
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
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:-)
telnet yourSmtpServer 587
that you are trying to reach
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.