我尝试使用TLS发送电子邮件,端口号为587,服务器名为smtp.gmail.com,但总是收到错误"error '8004020e'“。我将SSL设置为false,因为端口587身份验证是TLS。我的代码中有什么错误吗?
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = CreateObject("CDO.Configuration")
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = false
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xx@gmail.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xx"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objConfig.Fields.Update
Set objMail.Configuration = objConfig
objMail.From = "xx@gmail.com"
objMail.To = "yy@yahoo.com"
objMail.Subject = "Test EMAIL"
objMail.TextBody = "Test EMAIL"
objMail.HTMLBody = "fffffffffff"
objMail.Send
Set objMail = Nothing
发布于 2017-03-01 22:55:26
请改用端口465,并对Gmail或Amazon SES SMTP使用ssl (smtpusessl = True)。
并且还必须确保(登录到Gmail帐户邮箱,检查是否有消息,告诉你以前的失败尝试),“旧应用程序”的邮箱使用是启用的……(这是一个新的“功能”,可以在雅虎和谷歌邮件服务器上启用,因为不久前...如果不设置此选项,甚至可能某些移动电子邮件客户端将无法工作。)
https://stackoverflow.com/questions/32862506
复制相似问题