<small id='3Gcz3'></small><noframes id='3Gcz3'>

    <legend id='3Gcz3'><style id='3Gcz3'><dir id='3Gcz3'><q id='3Gcz3'></q></dir></style></legend>

    <tfoot id='3Gcz3'></tfoot>

    • <bdo id='3Gcz3'></bdo><ul id='3Gcz3'></ul>

    <i id='3Gcz3'><tr id='3Gcz3'><dt id='3Gcz3'><q id='3Gcz3'><span id='3Gcz3'><b id='3Gcz3'><form id='3Gcz3'><ins id='3Gcz3'></ins><ul id='3Gcz3'></ul><sub id='3Gcz3'></sub></form><legend id='3Gcz3'></legend><bdo id='3Gcz3'><pre id='3Gcz3'><center id='3Gcz3'></center></pre></bdo></b><th id='3Gcz3'></th></span></q></dt></tr></i><div id='3Gcz3'><tfoot id='3Gcz3'></tfoot><dl id='3Gcz3'><fieldset id='3Gcz3'></fieldset></dl></div>
    1. SmtpException:客户端或服务器仅配置为具有 ASCII 本地部分的电子邮件地址

      SmtpException: The client or server is only configured for e-mail addresses with ASCII local-parts(SmtpException:客户端或服务器仅配置为具有 ASCII 本地部分的电子邮件地址)

    2. <tfoot id='PtqW5'></tfoot>
      <legend id='PtqW5'><style id='PtqW5'><dir id='PtqW5'><q id='PtqW5'></q></dir></style></legend>
        <bdo id='PtqW5'></bdo><ul id='PtqW5'></ul>

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

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

                本文介绍了SmtpException:客户端或服务器仅配置为具有 ASCII 本地部分的电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                SmtpClient.Send() 方法在以下情况下抛出此异常我尝试向包含重音字符 (é) 的地址发送电子邮件:

                The SmtpClient.Send() method is throwing this exception when I try to send an email to an address containing an accentuated character (é):

                System.Net.Mail.SmtpException:客户端或服务器仅配置对于带有 ASCII 本地部分的电子邮件地址:léo.xxx@example.com.
                在 System.Net.Mail.MailAddress.GetAddress(布尔 allowUnicode)
                在 System.Net.Mail.SmtpClient.ValidateUnicodeRequirement(MailMessage...)
                在 System.Net.Mail.SmtpClient.Send(MailMessage 消息)

                System.Net.Mail.SmtpException: The client or server is only configured for e-mail addresses with ASCII local-parts: léo.xxx@example.com.
                at System.Net.Mail.MailAddress.GetAddress(Boolean allowUnicode)
                at System.Net.Mail.SmtpClient.ValidateUnicodeRequirement(MailMessage...)
                at System.Net.Mail.SmtpClient.Send(MailMessage message)

                消息的表述让我觉得可能有一个设置可以激活来完成这项工作,尽管我还没有找到关于这个主题的任何内容.

                The formulation of the message makes me thing there might be a setting that I can activate to make this work, though I haven't found anything on this subject.

                我尝试了多个 SMTP 服务器,包括 Gmail.以下是再现的相关位:

                I have tried several SMTP servers, including Gmail. Here are the relevant bits for a repro:

                代码

                var msg = new MailMessage();
                msg.Subject = "Test";
                msg.From = new MailAddress("xxx@gmail.com");
                msg.To.Add(new MailAddress("léo.yyy@gmail.com"));
                
                new SmtpClient().Send(msg);
                

                app.config

                <system.net>
                    <mailSettings>
                        <smtp from="xxx@gmail.com">
                            <network host="smtp.gmail.com" port="587" userName="xxx@gmail.com" password="password" enableSsl="true" />
                        </smtp>
                    </mailSettings>
                </system.net>
                

                推荐答案

                如果SmtpClient 实例的 aspx" rel="nofollow noreferrer">DeliveryFormat 属性设置为 SmtpDeliveryFormat.SevenBit (默认)然后您需要确保您的 SMTP 网关正在回复 .NET 在尝试发送电子邮件时发送 EHLO 时的 SMTPUTF8.SmtpClient 使用它来确定网关是否能够支持 UTF8.

                If the DeliveryFormat property of your SmtpClient instance is set to SmtpDeliveryFormat.SevenBit (the default) then you need to make sure your SMTP gateway is replying with SMTPUTF8 when sent EHLO by .NET while it's trying to send the email. SmtpClient uses this to work out if the gateway is able to support UTF8.

                根据 .NET Framework 4.5+ 和 .NET core 的源,接收服务器必须支持 UTF8 并且 DeliveryFormat 必须设置为 SmtpDeliveryFormat.International为了能够发送.

                According to the source for both .NET Framework 4.5+ and .NET core, the receiving server must support UTF8 and the DeliveryFormat must be set to SmtpDeliveryFormat.International in order to be able to send.

                有关最新逻辑和完整详细信息,请参阅 IsUnicodeSupported in:

                For the latest logic and full details, see IsUnicodeSupported in:

                • 当前 .NET 源代码
                • .NET Framework 参考源

                这篇关于SmtpException:客户端或服务器仅配置为具有 ASCII 本地部分的电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                Cannot remove items from ListBox(无法从列表框中删除项目)
                Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                Drag and drop from list to canvas on windows phone with MVVM(使用 MVVM 在 Windows 手机上从列表拖放到画布)
                Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                • <bdo id='BQlhT'></bdo><ul id='BQlhT'></ul>

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

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

                    <tfoot id='BQlhT'></tfoot>

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