1. <small id='0HtUD'></small><noframes id='0HtUD'>

        <tfoot id='0HtUD'></tfoot>
          <bdo id='0HtUD'></bdo><ul id='0HtUD'></ul>

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

        C# SMTP 身份验证失败,但凭据正确

        C# SMTP authentication failed but credentials are correct(C# SMTP 身份验证失败,但凭据正确)
          <tbody id='zqve2'></tbody>

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

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

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

                <legend id='zqve2'><style id='zqve2'><dir id='zqve2'><q id='zqve2'></q></dir></style></legend>
                • <tfoot id='zqve2'></tfoot>
                  本文介绍了C# SMTP 身份验证失败,但凭据正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这是我的问题:我编写了以下程序来测试我是否可以发送电子邮件:

                  Here is my problem: I wrote whe following program to test if I can send email:

                  class Program
                  {
                      static void Main(string[] args)
                      {
                          try {
                              Console.WriteLine("Mail To");
                              MailAddress to = new MailAddress("myemail@gmail.com");
                  
                              Console.WriteLine("Mail From");
                              MailAddress from = new MailAddress("me@businessdomain.it");
                  
                              MailMessage mail = new MailMessage(from, to);
                  
                              Console.WriteLine("Subject");
                              mail.Subject = "test";
                  
                              Console.WriteLine("Your Message");
                              mail.Body = "test";
                  
                              SmtpClient smtp = new SmtpClient();
                              smtp.Host = "mail.domain.it";
                              smtp.Port = 25;
                  
                              smtp.Credentials = new NetworkCredential(
                                  "username", "password");
                              smtp.EnableSsl = false;
                              Console.WriteLine("Sending email...");
                              smtp.Send(mail);
                          }catch(Exception e)
                          {
                              Console.WriteLine(e.Message);
                              Console.WriteLine(e.StackTrace);
                          }
                      }
                  }
                  

                  凭据是正确的(我使用 telnet、outlook 和 android 中的应用程序 k9mail 测试它们正常工作),如果我设置 gmail smtp 设置,该程序可以工作.我真的无法理解这个错误的原因.

                  The credentials are correct (I tested them using telnet, outlook and the app k9mail in android correctly work), the program works if I put gmail smtp setting. I really cannot understand the cause of this error.

                  使用 wireshark 我发现了正在发生的事情:S: 220 server1.business.it SMTP 服务器就绪
                  C: EHLO pc14
                  S: 250 server1.stargatenet.it 你好 [87.28.219.65] |250 流水线 |250 尺寸 25000000 |250 8BITMIME |第250章250 分块 |250 AUTH 登录 CRAM-MD5 DIGEST-MD5 |250 好的
                  C:AUTH登录用户:UsernameBase64
                  S: 334 VXNlcm5hbWU6
                  C:通过:PasswordBase64
                  S: 334 UGFzc3dvcmQ6

                  Using wireshark I have discovered what is happening: S: 220 server1.business.it SMTP Server ready
                  C: EHLO pc14
                  S: 250 server1.stargatenet.it Hello [87.28.219.65] | 250 PIPELINING | 250 SIZE 25000000 | 250 8BITMIME | 250 BINARYMIME | 250 CHUNKING | 250 AUTH LOGIN CRAM-MD5 DIGEST-MD5 | 250 Ok
                  C: AUTH login User: UsernameBase64
                  S: 334 VXNlcm5hbWU6
                  C: Pass: PasswordBase64
                  S: 334 UGFzc3dvcmQ6

                  似乎程序在被询问时没有输入凭据.这怎么可能?

                  It seems like the program is not entering the credentials when asked. How is that possible?

                  推荐答案

                  这个链接救了我的命:链接

                  这里很好地描述了我遇到的问题:即使用户名通过 AUTH LOGIN 传递,服务器也会再次使用 AUTH_LOGIN_Username_Challenge 进行响应.

                  here the problem I experienced is well described: even though the user name is passed with the AUTH LOGIN the server responds with the AUTH_LOGIN_Username_Challenge again.

                  此问题仅在使用 System.Net.Mail 时发生.该链接建议了三种可能的解决方案:

                  This problem happens only using System.Net.Mail. The link suggests tre possible solutions:

                  1)使用 CDOSYS(不发送带有 AUTH 登录的用户名)
                  2)使用System.Web.Mail(不发送带有AUTH登录的用户名)
                  3) 联系 SMTP 服务器所有者并让他们修复服务器.

                  1)Use CDOSYS (Does not send the User Name with the AUTH Login)
                  2)Use System.Web.Mail (Does not send the User Name with the AUTH Login)
                  3)Contact the SMTP Server owner and have them fix the server.

                  不幸的是,我不能成为 SMTP 服务器的所有者,所以我不得不使用 System.Web.Mail.我知道它已被弃用,但不幸的是,在这种情况下,IMO 没有其他选择.

                  Unfortunately I couldn't the SMTP server owner, so I had to use System.Web.Mail. I know it is deprecated but unfortunately in cases like this there is no other choice IMO.

                  这是我的工作代码:

                  System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();
                          msg.Body = message.Body;
                  
                          string smtpServer = "mail.business.it";
                          string userName = "username";
                          string password = "password";
                          int cdoBasic = 1;
                          int cdoSendUsingPort = 2;
                          if (userName.Length > 0)
                          {
                              msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
                              msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25);
                              msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort);
                              msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);
                              msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
                              msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
                          }
                          msg.To = message.Destination;
                          msg.From = "me@domain.it";
                          msg.Subject = message.Subject;
                          msg.BodyFormat = MailFormat.Html;//System.Text.Encoding.UTF8;
                          SmtpMail.SmtpServer = smtpServer;
                          SmtpMail.Send(msg);
                  

                  这个答案帮助我使用了System.Web.Mail.

                  This answer helped me in using System.Web.Mail.

                  这篇关于C# SMTP 身份验证失败,但凭据正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

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

                  1. <small id='IhFFj'></small><noframes id='IhFFj'>

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

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