What caused the Socket Exception while sending email from Console application?

别来无恙 提交于 2019-12-01 16:33:44

I had very similar situation once and it turned out that the antivirus was just blocking that port. Your possible options are listed here: http://social.msdn.microsoft.com/Forums/br/transactsql/thread/c083c2c6-f74e-42cd-a811-4329ff7aa5f1

Is port 25 enabled and available? For example this thread explains that is is possible for another service to have exclusive access to it.

Have you tried this code in another machine (with less security)? I don't mean that as part of a fix, but just to make sure that the code is OK by itself.

Try to play with EnableSsl. In msdn reason of exception:

EnableSsl is set to true, but the SMTP mail server did not advertise STARTTLS in the response to the EHLO command.

Also check StatusCode of the exception.

Either don't assign the port or don't use EnableSSL = true. Doing one of this will solve your problem.

You are trying to initiate a communication which is not allowed to be done this way.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!