为什么System.Net.Mail会出现“身份验证失败”而System.Web.Mail却没有?

时间:2022-09-24 08:30:01

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.

我正在通过第三方SMTP服务器从asp.net应用程序发送电子邮件。此服务器需要身份验证通常我会使用System.Net.Mail结合System.Net.NetworkCredential来完成此任务。

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.

在这种特殊情况下,我不断收到“身份验证失败”消息。我知道主机名,用户名和密码信息是正确的;我已成功通过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.

我最终使用System.Web.Mail发送消息并使用System.Web.Mail.MailMessage.Fields.Add来指定凭据。

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==".

看看Wireshark中的传输,我注意到初始AUTH命令略有不同。 Outlook和System.Web.Mail都发送“AUTH LOGIN”,其中System.Net.Mail发送“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.

搜索了一下后,我发现其他人也有类似的问题,但通常修复是使用中间中继服务器。我以为我会在这里发布问题,看看是否有人有任何想法。

1 个解决方案

#1


1  

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.

看起来System.Net.Mail版本正在发送某种类型的哈希或挑战,而System.Web.Mail版本则不是。是否有一个您正在使用的设置,而另一个设置中没有使用?或者,可能是设置NetworkCredential假定您要使用哈希或加密机制进行通信,而您发送到的服务器可能不支持该功能。

#1


1  

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.

看起来System.Net.Mail版本正在发送某种类型的哈希或挑战,而System.Web.Mail版本则不是。是否有一个您正在使用的设置,而另一个设置中没有使用?或者,可能是设置NetworkCredential假定您要使用哈希或加密机制进行通信,而您发送到的服务器可能不支持该功能。