我有一個小網站,有一個聯繫表格,使用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