通过TLS发送电子邮件

时间:2015-09-30 09:26:00

标签: email vbscript asp-classic email-integration 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

1 个答案:

答案 0 :(得分:2)

使用端口465代替使用ssl(smtpusessl = True)进行Gmail或Amazon SES SMTP。

还必须确保(登录到Gmail帐户邮箱,检查是否有消息,告诉您以前的尝试失败),以及"旧应用程序的邮箱使用情况"启用...(它是一个新的"功能",可以在雅虎和谷歌邮件服务器上启用,因为不久前...甚至可能一些移动电子邮件客户端将无法工作没有设定。)