【发布时间】:2021-01-06 17:02:24
【问题描述】:
IONOS 没有帮助。尤其是突然之间,表单停止发送电子邮件。
This文章很好的解释和帮助Sending email from webform using SMTP server
我得到的错误是相同的:SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应是:需要身份验证
这是我的 VB - 我接受了这里的建议,并将 From 与身份验证相同,但仍然没有运气。最初是objMM.From = New MailAddress(txtEmail.Text)。我也确实读过端口 25 可以工作,但这也不起作用。原来是587。
Sub btnSendFeedback_Click(sender as Object, e as 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 确定这是脚本问题。
【问题讨论】:
-
如果您使用的凭据不是来自 CredentialCache 的
DefaultNetworkCredentials(发送电子邮件时很有可能),您只需设置[object].Credentials = new NetworkCredentials(...)。UseDefaultCredentials默认为false,所以不需要设置。如果这样做,您还将重置Credentials属性值,无论之前的值是否为默认值。这同样适用于UseDefaultCredentials = true:您正在清除刚刚设置的Credentials。因此,只需设置Credentials属性即可。
标签: vb.net