1

我正在尝试使用 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)

谁能看到可能出了什么问题?

谢谢各位!

4

2 回答 2

3

我尝试使用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
于 2012-03-26T17:17:28.583 回答
1

尝试设置smtpusessl1(真)(我看到你把它设置为false

于 2012-03-12T15:35:02.753 回答