为什么 System.Net.Mail 会出现“身份验证失败”?而 System.Web.Mail 没有?
我正在通过第 3 方 SMTP 服务器从 ASP.NET 应用程序发送电子邮件。该服务器需要身份验证。一般来说,我会结合使用 System.Net.Mail 和 System.Net.NetworkCredential 来完成此任务。
在这种特殊情况下,我不断收到“身份验证失败”消息。我知道主机名、用户名和密码信息是正确的;我已成功通过 Outlook 发送邮件。
我最终求助于使用 System.Web.Mail 发送消息并使用 System.Web.Mail.MailMessage.Fields.Add 来指定凭据。
查看 Wireshark 中的传输,我注意到初始 AUTH 命令略有不同。 Outlook 和 System.Web.Mail 均发送“AUTH LOGIN”,而 System.Net.Mail 发送“AUTH LOGIN bWFpba==”。
经过一番搜索后,我发现其他人也有类似的问题,但通常的解决方法是使用中间中继服务器。我想我应该在这里发布问题,看看是否有人有任何想法。
I'm sending an email from an asp.net application via a 3rd party SMTP server. This server requires authentication. Generally I would use System.Net.Mail combined with System.Net.NetworkCredential to accomplish this.
In this particular case I keep getting an "authentication failed" message. I know the hostname, username, and password information is correct; I've successfully sent messages via Outlook.
I finally resorted to using System.Web.Mail to send the message and used System.Web.Mail.MailMessage.Fields.Add to specifiy the credentials.
Looking at the transmissions in Wireshark, I've noticed a slight difference in the initial AUTH command. Both Outlook and System.Web.Mail send "AUTH LOGIN" where System.Net.Mail sends "AUTH LOGIN bWFpba==".
After searching a bit, I've found others have the similar problems, but usually the fix is to use an intermediate relay server. I thought I'd post the question here to see if anyone has any ideas.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 System.Net.Mail 版本正在发送某种类型的哈希或质询,而 System.Web.Mail 版本则没有。是否存在您在一个设置中使用而在另一设置中未使用的设置?或者,设置 NetworkCredential 可能假设您想要使用散列或加密机制进行通信,而您发送到的服务器可能不支持该机制。
It looks like the System.Net.Mail version is sending a Hash or Challenge of some type while the System.Web.Mail version is not. Is there a setting that you are using in one that you are not using in another? Alternatively, it could be that setting the NetworkCredential assumes you want to use a Hashed or Encrypted mechanism for communication while the server you are sending to may not support that.