带有Google地址的CDO.Message.1错误'80040213'

时间:2014-02-12 00:54:18

标签: vbscript asp-classic cdo.message

试图将我们的ASP页面CDO移到gmail上时遇到了问题。它会让我发疯。我做了一些详尽的搜索,我认为我的代码是正确的,但我仍然得到了可怕的:CDO.Message.1错误'80040213'传输无法连接到服务器。在oMail.Send。任何想法将不胜感激。我开始认为它可能是服务器防火墙问题。

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0 
Const cdoBasic = 1 
Const cdoNTLM = 2 
Set oMail = CreateObject("CDO.Message") 

oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic 
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "info@domain.com"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

oMail.From = "info@domain.com"
oMail.To = "someone@domain.com"
oMail.Bcc = ""
'oMail.To = ""
oMail.Subject = ""

oMail.HTMLBody = "<font size='2' face='Verdana, Arial, Helvetica, sans-serif'>"

oMail.HTMLBody = oMail.HTMLBody + "Name: <b>"& request.form("Name")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Phone: <b>"& request.form("Phone")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Email: <b>"& request.form("Email")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Best Time to Call: <b>"& request.form("BestTime")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Question/Comment: <b>"& request.form("Comment")&"</b><br>"

oMail.HTMLBody = oMail.HTMLBody + "</font>"
oMail.Configuration.Fields.Update

oMail.Send 

Set oMail = Nothing 
Set oMailConfig = Nothing 

任何想法或建议将不胜感激。我已经尝试了所有谷歌sm​​tp端口25,465和567.我错过了什么?

1 个答案:

答案 0 :(得分:2)

直接来自Google's own instructions;

标准配置说明:

  

接收邮件(POP3)服务器 - 需要SSL: pop.gmail.com
  使用SSL:
  端口: 995
  发送邮件(SMTP)服务器 - 需要TLS或SSL: smtp.gmail.com

     
    

使用身份验证:
     TLS / STARTTLS的端口: 587
     SSL端口: 465

  
     

服务器超时大于1分钟,我们建议5周   全名或显示名称: [您的姓名]
  帐户名称或用户名:您的完整电子邮件地址(包括@ gmail.com或@ your_domain.com)
  电子邮件地址:您的电子邮件地址(username@gmail.com或username@your_domain.com)
  密码:您的Gmail密码

我还会检查你的服务器的dns分辨率为smtp.gmail.com并检查你的防火墙可能会阻塞端口465,作为测试尝试连接而不用SSL来查看你是否可以连接25(参见这篇文章 - {{ 3}}

对谷歌的建议:

  

如果您在发送邮件时遇到问题,但已确认邮件客户端中的SMTP加密处于活动状态,请尝试在其他端口(465或587)上配置SMTP服务器。