SMTP邮件与ASP CLASSIC发送错误

时间:2014-07-26 09:06:54

标签: email asp-classic smtp

我正在尝试使用smtp将邮件从我的网络服务器发送到其他邮件服务。我搜索网络,我发现了一个代码。所以我创建了一个名为cdosys.asp的示例页面,之后我将其放在我的godaddy服务器上并添加了必要的smtp地址但是当我发送它时给了我错误。

错误'8004020e'

/cdosys.asp,第42行

<%
    '----------------------------------------------------------------------------
    '
    '   Send email using the CDOSYS component
    '
    '   by Chris Hardy
    '   http://www.chrishardy.co.uk/
    '
    '----------------------------------------------------------------------------

  Option Explicit

  dim sName, sEmail, sMessage
    dim oCdoMail, oCdoConf, sConfURL

  if Request.Form("Action") <> "" then
    sName = Request.Form("Name")
    sEmail = Request.Form("Email")
    sMessage = Request.Form("Message")

        Set oCdoMail = Server.CreateObject("CDO.Message")
        Set oCdoConf = Server.CreateObject("CDO.Configuration")

        sConfURL = "http://schemas.microsoft.com/cdo/configuration/"

        with oCdoConf
            .Fields.Item(sConfURL & "sendusing") = 2
            .Fields.Item(sConfURL & "smtpserver") = "smtpout.secureserver.net"
            .Fields.Item(sConfURL & "smtpserverport") = 80
            .Fields.Update


        end with

        with oCdoMail
            .From = "noreply@myserver.com"
            .To = sEmail
            .Subject = "My message subject"
            .TextBody = sMessage
            .HTMLBody = sMessage
            .Configuration = oCdoConf
            .Send
        end with

        Set oCdoConf = Nothing
        Set oCdoMail = Nothing

    response.write "Thanks for your message!"
  else
%>
<form method="post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
<p>Name:<br /><input type="text" name="Name" /></p>
<p>E-mail:<br /><input type="text" name="Email" /></p>
<p>Message:<br /><textarea name="Message"></textarea></p>
<p><input type="submit" name="Action" value="Send" /></p>
</form>
<%
  end if
%>

1 个答案:

答案 0 :(得分:0)

我建议你尝试一些事情:

1 - 确保发件人地址有效。

2 - 尝试使用来自邮件服务器secureserver.net的有效帐户的发件人地址。

3 - 确保收件人地址有效。

4 - 尝试使用有效的帐户和密码对SMTP服务器进行身份验证,如下所示:

oCdoMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
oCdoMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
oCdoMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"

5 - 根据Godaddy support,您可能只能使用其邮件服务器relay-hosting.secureserver.net发送电子邮件。也许他们阻止端口25的SMTP流量。这是他们的代码示例:

<%
sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"


' Set the mail server configuration
Set objConfig=CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl)=2 ' cdoSendUsingPort
objConfig.Fields.Item(smtpUrl)="relay-hosting.secureserver.net"
objConfig.Fields.Update


' Create and send the mail
Set objMail=CreateObject("CDO.Message")
' Use the config object created above
Set objMail.Configuration=objConfig
objMail.From="sender@coolexample.com"
objMail.ReplyTo="sender@coolexample.com"
objMail.To="recipient@coolexample.com"
objMail.Subject="subject"
objMail.TextBody="body"
objMail.Send
%>