我正在尝试使用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的地方)
任何人都可以看到可能出错的地方吗?
谢谢大家!
答案 0 :(得分:2)
我尝试使用 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
答案 1 :(得分:1)
尝试将smtpusessl
设置为1
(true)(我看到您将其设置为false
)