我已尝试使用 TLS 发送电子邮件,端口号为 587,服务器名称为 smtp.gmail.com,但总是收到错误“错误‘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
最佳答案
改为使用端口 465 并为 Gmail 或 Amazon SES SMTP 使用 ssl (smtpusessl = True)。
并且还必须确保(登录到 Gmail 帐户邮箱,检查是否有消息,告诉您以前不成功的尝试)启用了“旧应用程序”的邮箱使用...(这是一个新“功能”,不久前就可以在 Yahoo 和 Google 邮件服务器上启用...如果未设置,甚至某些移动电子邮件客户端可能无法工作。)
关于vbscript - 通过 TLS 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32862506/