vbscript - 通过 TLS 发送电子邮件

标签 vbscript asp-classic email starttls

我已尝试使用 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/

相关文章:

scripting - 经典 ASP 脚本超时

html - 为什么 Flash 在 IE 中不显示

javascript - 将 AngularJS 表单发送到 NodeMailer 以发送电子邮件

php - 上传简历并发送电子邮件,在 codeigniter php 中显示空白页面

vbscript - 在 Windows 中检查端口可用性的 VBS 脚本

vbscript - 在 Windows 10 上运行的系统上设置本地计算机名称和静态 IP 地址

string - VBScript 中是否有任何内置函数可以将字符串重复 N 次?

arrays - 关于动态数组的困惑

encoding - 如何停止 Server.HtmlEncode 编码 UTF8 字符?

php - 无法使用 PHP 连接到 IMAP