2014-07-26 94 views
-1

我想從我的網絡服務器發送郵件到其他郵件服務使用smtp。我搜索網絡,我發現了一個代碼。所以我創建了一個名爲cdosys.asp的示例頁面,在此之後,我放置在我的godaddy服務器上並添加了必需的smtp地址,但是當我發送它時會給我和錯誤。SMPT郵件發送錯誤與ASP CLASSIC

錯誤 '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 = "[email protected]" 
      .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 
%> 

回答

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") ="[email protected]" 
oCdoMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword" 

5 - 據Godaddy support你可能只能夠使用他們的郵件服務器中繼主機發送電子郵件。 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="[email protected]" 
objMail.ReplyTo="[email protected]" 
objMail.To="[email protected]" 
objMail.Subject="subject" 
objMail.TextBody="body" 
objMail.Send 
%> 
+0

仍然給出了同樣的錯誤消息 – blay

+0

看起來像Godaddy的有,你必須使用特定的郵件服務器。在我編輯的答案中見編號5。 – johna

+0

是的,它的工作。它必須處理smpt服務器 – blay