1

我有兴趣通过 ASP 页面发送电子邮件。我在互联网上照顾它,我发现了一些东西。

<%
    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 
   %>

但它没有向我发送电子邮件,它说“流量无法连接到服务器”我应该在代码中更改什么?

非常感谢。

4

1 回答 1

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
于 2013-01-03T10:02:57.613 回答