【问题标题】:Send mail with CDO through Google Apps gives transport error: CDO.Message.1 error '80040213'通过 Google Apps 使用 CDO 发送邮件会出现传输错误:CDO.Message.1 错误“80040213”
【发布时间】:2012-03-29 00:06:32
【问题描述】:

我正在尝试使用 Google Apps 帐户作为 SMTP 服务器从旧版经典 asp 脚本发送联系查询电子邮件。我必须测试的代码如下:

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 

'This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.thedomain.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 ' or 587
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

' Google apps mail servers require outgoing authentication. Use a valid email address and password registered with Google Apps.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="info@thedomain.com" 'your Google apps mailbox address
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="password" 'Google apps password for that mailbox

ObjSendMail.Configuration.Fields.Update

ObjSendMail.To = "me@mydomain.net"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "info@thedomain.com"

' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"

ObjSendMail.Send
Set ObjSendMail = Nothing 

我已尝试使用 465 和 587 端口号。我已尝试将 mail.thedomain.com 和 smtp.thedomain.com 以及 mail.gmail.com 和 smtp.gmail.com 作为 SMTP 服务器,但没有任何效果。我已经使用脚本中的电子邮件地址和密码登录了 Google Apps 帐户,因此这些详细信息绝对正确。

我只能得到以下错误:

CDO.Message.1 error '80040213'

The transport failed to connect to the server.

/_test-email.asp, line 46 

(第 46 行是 ObjSendMail.Send)

谁能看出哪里出了问题?

谢谢各位!

【问题讨论】:

  • @Calon 停止以相同方式编辑所有问题...

标签: asp-classic google-apps cdo.message


【解决方案1】:

我尝试使用 Gmail smtp 服务器并对您的代码稍作更改,效果非常棒。

只需修改这 3 个参数即可。

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1

【讨论】:

    【解决方案2】:

    尝试将smtpusessl 设置为1 (true)(我看到您已将其设置为false

    【讨论】:

    • 谢谢 - 我忘了提到我已经尝试过该字段的真假(以及 1 和 0),但仍然得到相同的错误。可能与本地主机有关(某种防火墙问题或“mail.thedomain.com”地址在本地路由,因此无法连接??)我不知道服务器管理员和托管公司也没有提供太多帮助:(
    • 我刚刚使用我的 Google Apps 帐户 smtpserver = "smtp.gmail.com", smtpserverport = 465, smtpusessl = 1 对其进行了测试,它运行良好。如果它仍然无法正常工作,则表明您的防火墙存在问题?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-29
    • 2012-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多