Problem:When using System.Net.Mail.SmtpClient to send email I received the following error with the resulting stacktrace:
System.Net.Mail.SmtpException: Failure sending mail.
Failure sending mail. Unable to connect to the remote server
An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) System
Solution:If you run into this error from your dev (local) host try disabling any anti-virus software. The software is blocking email from being sent by mass emailing worms and it treats the request above as such.
Notice this line in the stacktrace
An established connection was aborted by the software in your host machineThis is the anti-virus software blocking your request.
Credits:After reading this
thread from Microsofts forums, I found the solution near the bottom. Oddly enough, it was not set as the "accepted answer" like it should have been hence this posting.