<legend id='ZxBtE'><style id='ZxBtE'><dir id='ZxBtE'><q id='ZxBtE'></q></dir></style></legend>

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

  • <tfoot id='ZxBtE'></tfoot>

      • <bdo id='ZxBtE'></bdo><ul id='ZxBtE'></ul>

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

      2. SMTP 服务器需要安全连接或客户端未通过身份验证.服务器响应是:5.5.1 需要身份验证?

        The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required?(SMTP 服务器需要安全连接或客户端未通过身份验证.服务器响应是:5.5.1 需要身份验证?) - IT屋-程序员软件开发
          <bdo id='18eF3'></bdo><ul id='18eF3'></ul>

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

                <tbody id='18eF3'></tbody>
              <legend id='18eF3'><style id='18eF3'><dir id='18eF3'><q id='18eF3'></q></dir></style></legend>
                <tfoot id='18eF3'></tfoot>

                  <small id='18eF3'></small><noframes id='18eF3'>

                1. 本文介绍了SMTP 服务器需要安全连接或客户端未通过身份验证.服务器响应是:5.5.1 需要身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想从我的应用程序中发送一封电子邮件,并且我已经编写了以下用于发送邮件的代码

                  I want to send an email from my application and i have written following code for sending mail

                      MailMessage msg = new MailMessage();
                  
                      msg.From = new MailAddress("mymailid");
                      msg.To.Add("receipientid");
                      msg.Subject = "test";
                      msg.Body = "Test Content";
                      msg.Priority = MailPriority.High;
                  
                      SmtpClient client = new SmtpClient();
                  
                      client.Credentials = new NetworkCredential("mymailid", "mypassword", "smtp.gmail.com");
                      client.Host = "smtp.gmail.com";
                      client.Port = 587;
                      client.DeliveryMethod = SmtpDeliveryMethod.Network;
                      client.EnableSsl = true;
                      client.UseDefaultCredentials = true;
                  
                      client.Send(msg);
                  

                  我在本地主机上运行它,所以我在发送它时犯了什么错误.

                  I am running it on localhost so what mistake i am doing to send it.

                  当我发送按钮时,它会出现类似的错误

                  When i send button it gives an error like

                  SMTP 服务器需要安全连接,或者客户端没有认证.服务器响应是:5.5.1 身份验证必需.

                  Web.config 文件中的代码

                  Code in Web.config file

                   <appSettings>
                      <add key="webpages:Version" value="2.0.0.0" />
                      <add key="webpages:Enabled" value="false" />
                      <add key="PreserveLoginUrl" value="true" />
                      <add key="ClientValidationEnabled" value="true" />
                      <add key="UnobtrusiveJavaScriptEnabled" value="true" />   
                      <add key="smtpServer" value="smtp.gmail.com" />
                      <add key="EnableSsl" value = "true"/>
                      <add key="smtpPort" value="587" />
                      <add key="smtpUser" value="sender@gmail.com" />
                      <add key="smtpPass" value="mypassword" />
                      <add key="adminEmail" value="sender@gmail.com" />
                    </appSettings>
                    <system.net>
                      <mailSettings>
                        <smtp from="sender@gmail.com">
                          <network host="smtp.gmail.com" password="mypassword" port="587" userName="sender@gmail.com"  enableSsl="true"/>
                        </smtp>
                      </mailSettings>
                    </system.net>
                  

                  我应该怎么做才能解决这个错误并发送邮件??

                  what should i do to solve this error and send mail??

                  推荐答案

                  首先检查gmail的安全相关问题.您可能在 gmail 中启用了双重身份验证.如果您收到任何安全警报,还请检查您的 gmail 收件箱.在这种情况下,请检查@mjb 的其他答案,如下所示

                  First check for gmail's security related issues. You may have enabled double authentication in gmail. Also check your gmail inbox if you are getting any security alerts. In such cases check other answer of @mjb as below

                  以下是我总是首先检查此类问题的非常普遍的事情

                  Below is the very general thing that i always check first for such issues

                  client.UseDefaultCredentials = true;
                  

                  将其设置为 false.

                  set it to false.

                  注意@Joe King 的 answer - 您必须设置 client.UseDefaultCredentials before 设置客户端.凭据

                  Note @Joe King's answer - you must set client.UseDefaultCredentials before you set client.Credentials

                  这篇关于SMTP 服务器需要安全连接或客户端未通过身份验证.服务器响应是:5.5.1 需要身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 列表框上的取消选择)

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

                      • <bdo id='3dyve'></bdo><ul id='3dyve'></ul>
                          <tbody id='3dyve'></tbody>

                        • <tfoot id='3dyve'></tfoot><legend id='3dyve'><style id='3dyve'><dir id='3dyve'><q id='3dyve'></q></dir></style></legend>

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