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

时间:2020-09-20 10:42:20

标签: vb.net

IONOS没有帮助。尤其是突然之间,表单停止发送电子邮件。

This文章对Sending email from webform using SMTP server

进行了很好的说明和帮助

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

这是我的VB-我接受了这里的建议,使From与身份验证相同,但还是没有运气。最初是objMM.From = New MailAddress(txtEmail.Text)。我确实也读过25端口可以工作,但这也不起作用。它最初是587

Sub btnSendFeedback_Click(发送者为对象,e为EventArgs)

'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 

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

1 个答案:

答案 0 :(得分:0)

fine manual for SmtpClient.Credentials说:

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

因此,我希望您的代码仅包含UseDefaultCredentials的提及,以便将其设置为False。

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