Vb.net 服务器响应为:即使提供了身份验证,也需要身份验证

Vb.net 服务器响应为:即使提供了身份验证,也需要身份验证,vb.net,Vb.net,离子是没有帮助的。尤其是当表单突然停止发送电子邮件时 这篇文章解释得很好,也很有帮助 我得到的错误与此相同:SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:需要身份验证 这是我的VB-我接受了这里的建议,并使来自的与身份验证相同,但仍然没有运气。最初它是objMM.From=新邮件地址(txtEmail.Text)。我也读到端口25可以工作,但这也不行。它最初是587 子BTN发送反馈\u单击(发送者作为对象,e作为事件参数) 我想知道这里还有什么问题吗?IONOS确信这是一

离子是没有帮助的。尤其是当表单突然停止发送电子邮件时

这篇文章解释得很好,也很有帮助

我得到的错误与此相同:SMTP服务器需要安全连接,或者客户端未通过身份验证。服务器响应为:需要身份验证

这是我的VB-我接受了这里的建议,并使来自的
与身份验证相同,但仍然没有运气。最初它是
objMM.From=新邮件地址(txtEmail.Text)
。我也读到端口25可以工作,但这也不行。它最初是
587

子BTN发送反馈\u单击(发送者作为对象,e作为事件参数)

我想知道这里还有什么问题吗?IONOS确信这是一个脚本问题。

说:

某些SMTP服务器要求在服务器代表其发送电子邮件之前对客户端进行身份验证。要使用默认网络凭据,可以将UseDefaultCredentials设置为true,而不是设置[smtpClient.credentials]属性。如果UseDefaultCredentials属性设置为false,则连接到服务器时,凭据属性中设置的值将用于凭据。如果UseDefaultCredentials属性设置为false,并且尚未设置Credentials属性,则邮件将以匿名方式发送到服务器

因此,我希望您的代码只包含一次UseDefaultCredentials,以便将其设置为False


当然,除非您在CredentialCache中将这些凭据配置为默认凭据。。在这种情况下,在此处再次提及它们是多余的

如果您使用的凭据不是来自凭据缓存的
DefaultNetworkCredentials
(发送电子邮件时很有可能),则只需设置
[object]。凭据=新网络凭据(…)
UseDefaultCredentials
默认为
false
,因此您无需进行设置。如果您这样做,您也会重置
凭证
属性值,无论先前的值是否为默认值。这同样适用于
UseDefaultCredentials=true
:您正在清除刚刚设置的
凭据。因此,只需设置
Credentials
属性,就可以了。
'Create an instance of the MailMessage class
Dim objMM as New MailMessage()

'Set the properties - send the email to the person who filled out the
'feedback form.
objMM.To.Add("receiver@receiver.com")
objMM.From = New MailAddress("website@domain.co.uk")

'Send the email in text format
objMM.IsBodyHtml = False

'Set the priority - options are High, Low, and Normal
objMM.Priority = MailPriority.Normal

'Set the subject
objMM.Subject = "Subject"

'Set the body
objMM.Body = " various long boring fields here . . . "

Dim smtp As New SmtpClient()
    smtp.Host = "smtp.ionos.com"
    smtp.EnableSsl = True
    smtp.UseDefaultCredentials = False
    smtp.Credentials = New Net.NetworkCredential("website@domain.co.uk", "passwordhere")
    smtp.UseDefaultCredentials = True
    smtp.Port = 587

'Send method of the SmtpMail class
smtp.Send(objMM)

End Sub