我有一个小网站,有一个联系表格,使用gmail的smtp发送电子邮件。 下面的代码:使用Gmail发送电子邮件与VB.NET错误smtp
Dim MyMailMessage As New System.Net.Mail.MailMessage()
'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress("[email protected]")
MyMailMessage.To.Add("[email protected]")
MyMailMessage.Subject = "MSG"
MyMailMessage.IsBodyHtml = True
MyMailMessage.Body = "TEXT"
'Create the SMTPClient object and specify the SMTP GMail server
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("user", "pass")
SMTPServer.EnableSsl = True
Try
SMTPServer.Send(MyMailMessage)
Return True
Catch exx As SmtpException
Throw exx
End Try
我得到的错误是:
5.5.4 HELO/EHLO参数无效,关闭连接。 ks5sm2862700wjb.13 - gsmtp
是您在实际使用的地址之上显示的电子邮件地址?如果您使用的电子邮件地址中存在无效语法,则可能会收到5.5.4错误。 – Dustin
不,即时通讯使用正常的合法电子邮件地址。 – user1578139
HELO/EHLO系统尝试检测垃圾邮件并将其拦截。该消息的ks5sm2862700wjb.13 - gsmtp部分似乎表明gmail正在阻止它,因为它认为它是垃圾邮件(或者是可疑的)。您是否尝试使用.IsBodyHtml = False发送测试消息? – Dustin