<%
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "smtp.gmail.com"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = Request.Form("From")
.To = Request.Form("To")
.Subject = Request.Form("Subject")
.TextBody = Request.Form("Body")
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>
但它没有向我发送电子邮件,其中说“流量无法连接到服务器”,我应该在代码中更改什么?
非常感谢。
答案 0 :(得分:0)
我认为您必须为smtp服务器设置用户名和密码,并将“smtpauthenticate”属性设置为true:
.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.item("http://schemas.microsoft.com/cdo/configuration/sendusername") = usrName
.item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = pwd