<small id='G0rPW'></small><noframes id='G0rPW'>

<i id='G0rPW'><tr id='G0rPW'><dt id='G0rPW'><q id='G0rPW'><span id='G0rPW'><b id='G0rPW'><form id='G0rPW'><ins id='G0rPW'></ins><ul id='G0rPW'></ul><sub id='G0rPW'></sub></form><legend id='G0rPW'></legend><bdo id='G0rPW'><pre id='G0rPW'><center id='G0rPW'></center></pre></bdo></b><th id='G0rPW'></th></span></q></dt></tr></i><div id='G0rPW'><tfoot id='G0rPW'></tfoot><dl id='G0rPW'><fieldset id='G0rPW'></fieldset></dl></div>

        <bdo id='G0rPW'></bdo><ul id='G0rPW'></ul>
    1. <tfoot id='G0rPW'></tfoot>

      1. <legend id='G0rPW'><style id='G0rPW'><dir id='G0rPW'><q id='G0rPW'></q></dir></style></legend>

        SmtpException:无法从传输连接读取数据:net_io_connectionclosed

        时间:2023-10-06
        <tfoot id='hI8gQ'></tfoot>

            <legend id='hI8gQ'><style id='hI8gQ'><dir id='hI8gQ'><q id='hI8gQ'></q></dir></style></legend>
              <tbody id='hI8gQ'></tbody>

            <small id='hI8gQ'></small><noframes id='hI8gQ'>

              <bdo id='hI8gQ'></bdo><ul id='hI8gQ'></ul>
                  <i id='hI8gQ'><tr id='hI8gQ'><dt id='hI8gQ'><q id='hI8gQ'><span id='hI8gQ'><b id='hI8gQ'><form id='hI8gQ'><ins id='hI8gQ'></ins><ul id='hI8gQ'></ul><sub id='hI8gQ'></sub></form><legend id='hI8gQ'></legend><bdo id='hI8gQ'><pre id='hI8gQ'><center id='hI8gQ'></center></pre></bdo></b><th id='hI8gQ'></th></span></q></dt></tr></i><div id='hI8gQ'><tfoot id='hI8gQ'></tfoot><dl id='hI8gQ'><fieldset id='hI8gQ'></fieldset></dl></div>

                  本文介绍了SmtpException:无法从传输连接读取数据:net_io_connectionclosed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 SmtpClient 库通过以下方式发送电子邮件:

                  I am using the SmtpClient library to send emails using the following:

                  SmtpClient client = new SmtpClient();
                  client.Host = "hostname";
                  client.Port = 465;
                  client.DeliveryMethod = SmtpDeliveryMethod.Network;
                  client.UseDefaultCredentials = false;
                  client.EnableSsl = true;
                  client.Credentials = new NetworkCredential("User", "Pass);
                  client.Send("from@hostname", "to@hostname", "Subject", "Body");
                  

                  代码在我的测试环境中运行良好,但是当我使用生产 SMTP 服务器时,代码失败并出现 SmtpException发送邮件失败".带有内部 IOException 无法从传输连接读取数据:net_io_connectionclosed".

                  The code works fine in my test environment, but when I use production SMTP servers, the code fails with an SmtpException "Failure sending mail." with an inner IOException "Unable to read data from the transport connection: net_io_connectionclosed".

                  我已经确认防火墙不是问题.端口在客户端和服务器之间打开得很好.我不确定还有什么可能引发此错误.

                  I've confirmed that firewalls are not an issue. The port opens just fine between the client and the server. I'm not sure what else could throw this error.

                  推荐答案

                  Super Redux 版本

                  尝试使用端口 587 而不是 465.端口 465 在技术上已被弃用.

                  Try port 587 instead of 465. Port 465 is technically deprecated.

                  经过一堆数据包嗅探后,我想通了.首先,这是一个简短的答案:

                  After a bunch of packet sniffing I figured it out. First, here's the short answer:

                  .NET SmtpClient 支持通过 STARTTLS 进行加密.如果设置了 EnableSsl 标志,则服务器必须使用 STARTTLS 响应 EHLO,否则将抛出异常.请参阅 MSDN 文档了解更多详情.

                  The .NET SmtpClient only supports encryption via STARTTLS. If the EnableSsl flag is set, the server must respond to EHLO with a STARTTLS, otherwise it will throw an exception. See the MSDN documentation for more details.

                  其次,为将来偶然发现此问题的人提供的快速 SMTP 历史课程:

                  Second, a quick SMTP history lesson for those who stumble upon this problem in the future:

                  过去,当服务还想提供加密时,它们被分配了一个不同的端口号,并在该端口号上立即启动了 SSL 连接.随着时间的推移,他们意识到为一个服务浪费两个端口号是愚蠢的,他们设计了一种服务方法,允许使用 STARTTLS 在同一个端口上进行明文和加密.通信将使用明文开始,然后使用 STARTTLS 命令升级到加密连接.STARTTLS 成为 SMTP 加密的标准.不幸的是,在实施新标准时总是会发生这种情况,与那里的所有客户端和服务器的兼容性都是大杂烩.

                  Back in the day, when services wanted to also offer encryption they were assigned a different port number, and on that port number they immediately initiated an SSL connection. As time went on they realized it was silly to waste two port numbers for one service and they devised a way for services to allow plaintext and encryption on the same port using STARTTLS. Communication would start using plaintext, then use the STARTTLS command to upgrade to an encrypted connection. STARTTLS became the standard for SMTP encryption. Unfortunately, as it always happens when a new standard is implemented, there is a hodgepodge of compatibility with all the clients and servers out there.

                  在我的例子中,我的用户试图将软件连接到强制立即 SSL 连接的服务器,这是 Microsoft 在 .NET 中不支持的旧方法.

                  In my case, my user was trying to connect the software to a server that was forcing an immediate SSL connection, which is the legacy method that is not supported by Microsoft in .NET.

                  这篇关于SmtpException:无法从传输连接读取数据:net_io_connectionclosed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:5.7.57 SMTP - 在 MAIL FROM 错误期间,客户端未通过身份验证发送匿名邮件 下一篇:在c#中通过gmail发送邮件时更改发件人地址

                  相关文章

                1. <i id='uGds0'><tr id='uGds0'><dt id='uGds0'><q id='uGds0'><span id='uGds0'><b id='uGds0'><form id='uGds0'><ins id='uGds0'></ins><ul id='uGds0'></ul><sub id='uGds0'></sub></form><legend id='uGds0'></legend><bdo id='uGds0'><pre id='uGds0'><center id='uGds0'></center></pre></bdo></b><th id='uGds0'></th></span></q></dt></tr></i><div id='uGds0'><tfoot id='uGds0'></tfoot><dl id='uGds0'><fieldset id='uGds0'></fieldset></dl></div>

                    <tfoot id='uGds0'></tfoot>

                        <bdo id='uGds0'></bdo><ul id='uGds0'></ul>

                      <small id='uGds0'></small><noframes id='uGds0'>

                    1. <legend id='uGds0'><style id='uGds0'><dir id='uGds0'><q id='uGds0'></q></dir></style></legend>