2013-04-18 3 views
1

웹 사이트에서 이메일을 보내는 동안 양식을 제출할 때 문제가 있습니다. 양식은 다음 위치에서 찾을 수 있습니다.제출 양식이 asp에서 작동하지 않습니다

http://www.someone.com/medicalights/contact.htm

나는 이메일을 보내 SMTPsvg.Mailer 객체를 사용하고 있습니다. 이 개체가 서버에서 지원되는지 여부 및 그렇다면 원격 호스트 속성에서 localhost를 사용할 수 있습니까? 나는 또한 CDONTS를 시도했습니다. MailCDO.Message 그러나 이들은 또한 잘 작동하지 않습니다. 이 문제에 관해 호스팅 업체의 지원 부서에 문의하십시오.

다음 코드는 이메일을 보내는 데 사용됩니다.

설정 메일러 = Server.CreateObject를 ("SMTPsvg.Mailer")는

Mailer.RemoteHost = "localhost" 
Mailer.ReturnReceipt = false 
Mailer.ConfirmRead = false 
Mailer.Priority = 1 
Mailer.Urgent = false 
Mailer.Timeout = 30 

Mailer.FromName = "someone.com" 
Mailer.FromAddress = "[email protected]" 
Mailer.AddRecipient "[email protected]", "[email protected]" 
Mailer.Subject = "CONTACT US Request" 
Mailer.BodyText = Body 

SendMail = Mailer.SendMail 

나는 그것의 완벽 작업을 다른 웹 사이트에 대한 동일한 코드를 사용하고 있지만이 하나하지와 같은 주소로 이메일을 보내는 두 웹 사이트의 문의 양식 .

+0

CDOSYS를 사용해 보셨습니까? SMTPsvg.Mailer는 타사 구성 요소로 Windows 서버에 기본적으로 설치되지 않습니다. CDONTS는 NT 서버에서는 표준이지만 CDOSYS로 대체되었습니다. – John

답변

0

양식에 대한 링크가 작동하지 않습니다. 양식의 HTML과 제출 된 데이터를 읽는 ASP 코드를보고 싶습니다. 나는 또한 메일을 보내기 위해 CDOSYS 코드를 사용하는 John의 추천에 동의합니다. 아마 그게 너의 문제 야.

<% 
function email(s_from,s_reply_to,s_recipients,s_bcc,s_subject,s_msg,s_type,s_msg_error_add,s_remote_host) 

    if (s_msg_error_add<>"") then s_msg_error_add = "<hr>" & vbCrLf & s_msg_error_add 
    if (s_remote_host="default") then s_remote_host = application("s_mail_server") 
    if (s_remote_host="") then s_remote_host = "localhost" 
    s_remote_host=lcase(s_remote_host) 

    's_recipients looks like "Scott <[email protected]>; Sue <[email protected]>" etc 

    s_from = replace(s_from,","," ",1,-1,1) 
    s_from = replace(s_from," "," ",1,-1,1) 
    s_from = replace(s_from,"[","<",1,-1,1) 
    s_from = replace(s_from,"]",">",1,-1,1) 

    if (s_reply_to<>"") then 
     s_reply_to = replace(s_reply_to,","," ",1,-1,1) 
     s_reply_to = replace(s_reply_to," "," ",1,-1,1) 
     s_reply_to = replace(s_reply_to,"[","<",1,-1,1) 
     s_reply_to = replace(s_reply_to,"]",">",1,-1,1) 
    end if 

    s_recipients = replace(s_recipients,",",";",1,-1,1) 
    s_recipients = replace(s_recipients," "," ",1,-1,1) 
    s_recipients = replace(s_recipients,"[","<",1,-1,1) 
    s_recipients = replace(s_recipients,"]",">",1,-1,1) 

    if (s_bcc<>"") then 
     s_bcc = replace(s_bcc,","," ",1,-1,1) 
     s_bcc = replace(s_bcc," "," ",1,-1,1) 
     s_bcc = replace(s_bcc,"[","<",1,-1,1) 
     s_bcc = replace(s_bcc,"]",">",1,-1,1) 
    end if 

    err.clear 

    Dim MailerConfig 
    Dim Mailer 
    Dim strRet 
    dim sch 

    strRet = "" 
    sch = "http://schemas.microsoft.com/cdo/configuration/" 

    Set MailerConfig = CreateObject("CDO.Configuration") 
    Set Mailer = CreateObject("CDO.Message") 

    With MailerConfig.Fields 
     '.Item(sch & "sendusing") = 2 'send using port - if err then this is really "SendUsingMethod" 
     '.Item(sch & "sendusingmethod") = 2 'send using port - if err then this is really "SendUsingMethod" 
     .Item(sch & "smtpconnectiontimeout") = 900 
     '.Item(sch & "smtpauthenticate") = 1 'use basic (clear-text) authentication 
     .Item(sch & "smtpserver") = s_remote_host 
     '.Item(sch & "smtpserverport") = 25 
     '.Item(sch & "sendusername") = SMAUTHUSER 
     '.Item(sch & "sendpassword") = SMAUTHPASS 
     .Update 
    End With 
    Mailer.Configuration = MailerConfig 

    'Mailer.Fields(cdoImportance) = 1 
    'Mailer.Fields("urn:schemas:mailheader:X-MSMail-Priority") = 1 
    'Mailer.Fields("urn:schemas:mailheader:X-Mailer") = "" 
    'Mailer.Fields.Update 

    '-- Set the Mail Properties 

    'on error resume next 

    Mailer.From = s_from 
    Mailer.To = s_recipients 
    if (s_reply_to<>"" and s_reply_to<>"na") then Mailer.ReplyTo = s_reply_to 

    b_redirect=false 

    if (err.number<>0 and err.number<>13) then 
     session("msg") = "Error in i_fn_email_cdo.asp line 72, Error: " & err.number & "<br>" & err.description 
     if (b_redirect) then response.redirect ("error_report.asp?send_mail=yes") 
    end if 

    if (s_bcc<>"" AND s_bcc<>"na" AND s_bcc<>"n/a") then Mailer.BCC = s_bcc 

    if (err.number<>0 and err.number<>13) then 
     session("msg") = "Error in i_fn_email_cdo.asp line 79, Error: " & err.number & "<br>" & err.description 
     if (b_redirect) then response.redirect ("error_report.asp?send_mail=yes") 
    end if 

    Mailer.Subject = s_subject 

    if (err.number<>0 and err.number<>13) then 
     session("msg") = "Error in i_fn_email_cdo.asp line 86, Error: " & err.number & "<br>" & err.description 
     if (b_redirect) then response.redirect ("error_report.asp?send_mail=yes") 
    end if 

    if (s_type="html") then 
     Mailer.AutoGenerateTextBody = True 
     s_msg = replace(s_msg,vbCrLf,"<br>",1,-1,1) 
    else 
     Mailer.AutoGenerateTextBody = False   
    end if 

    if (err.number<>0 and err.number<>13) then 
     session("msg") = "Error in i_fn_email_cdo.asp line 103, Error: " & err.number & "<br>" & err.description 
     if (b_redirect) then response.redirect ("error_report.asp?send_mail=yes") 
    end if 

    Mailer.MimeFormatted = False 

    if (err.number<>0 and err.number<>13) then 
     session("msg") = "Error in i_fn_email_cdo.asp line 110, Error: " & err.number & "<br>" & err.description 
     if (b_redirect) then response.redirect ("error_report.asp?send_mail=yes") 
    end if 

    if (s_type = "text") then 
     Mailer.TextBody = fn_dirty(s_msg) 
    else 
     's_msg_html = replace(s_msg,vbCrLf,"<br>",1,-1,1) 
     s_msg_html = s_msg 
     Mailer.HTMLBody = fn_dirty(s_msg_html) 
    end if 

    if (err.number<>0 and err.number<>13) then 
     session("msg") = "Error in i_fn_email_cdo.asp line 123, Error: " & err.number & "<br>" & err.description 
     if (b_redirect) then response.redirect ("error_report.asp?send_mail=yes") 
    end if 

    '-- Fire off the email message 

    Mailer.Send 

    if (err.number<>0 and err.number<>13) then 
     Select Case err.Number 
      Case -2147220973 
       strRet = " Failure to Send Report Message - Server Not Found" & vbCrLf & " Error: " & err.Number & " - " & err.Description 
      Case -2147220975 
       strRet = " Failure to Send Report Message - Server Authentication Failed" & vbCrLf & " Error: " & err.Number & " - " & err.Description 
      Case Else 
       strRet = " Failure to Send Report Message - Error: " & err.Number & " - " & err.Description 
     End Select 

     msg = "<br>Error in i_fn_email_cdo.asp: " & strRet & "<br><br>" 

     msg = msg & "remote host = " & s_remote_host & "<br>" 
     s_from = replace(s_from,"<","[",1,-1,1) 
     s_from = replace(s_from,">","]",1,-1,1) 
     s_reply_to = replace(s_reply_to,"<","]",1,-1,1) 
     s_reply_to = replace(s_reply_to,">","[",1,-1,1) 
     s_recipients = replace(s_recipients,"<","[",1,-1,1) 
     s_recipients = replace(s_recipients,">","]",1,-1,1) 
     s_bcc = replace(s_bcc,"<","[",1,-1,1) 
     s_bcc = replace(s_bcc,">","]",1,-1,1) 

     msg = msg & "from = " & s_from & "<br>" 
     msg = msg & "to = " & s_recipients & "<br>" 
     msg = msg & "subject = " & s_subject & "<br>" 
     msg = msg & "recipients = " & s_recipients & "<br><br>" 

     if (s_type = "text") then 
      msg = msg & s_msg 
     else 
      msg = msg & s_msg_html 
     end if 
     msg = msg & "<br>"  
     msg = msg & s_msg_error_add 
     session("msg") = msg 
     Set Mailer = Nothing 
     set MailerConfig = nothing 

     if (b_redirect) then response.redirect ("error_report.asp?send_mail=yes") 
    end if 

    Set Mailer = Nothing 
    set MailerConfig = nothing 

    email = true 

end function 

Function fn_dirty(FixWhat) 
    if (isnull(FixWhat) or FixWhat="") then 
     FixWhat="" 
    else 
     FixWhat=trim(FixWhat) 
     FixWhat=replace(FixWhat,"<ahref","<a href",1,-1,1) 
     FixWhat=replace(FixWhat,"<spanclass","<span class",1,-1,1) 
     FixWhat=replace(FixWhat," "," ",1,-1,1) 
     FixWhat=replace(FixWhat,"&#146;","'",1,-1,1) 
     FixWhat=replace(FixWhat,"&apos;","'",1,-1,1) 
     FixWhat=replace(FixWhat,"%27","'",1,-1,1) 
     FixWhat=replace(FixWhat,"&#39;","'",1,-1,1) 
     FixWhat=replace(FixWhat,"&#146;","'",1,-1,1) 
     FixWhat=replace(FixWhat,"&#47;","/",1,-1,1) 
     FixWhat=replace(FixWhat,"''''","'''",1,-1,1) 
     FixWhat=replace(FixWhat,"&#34;",chr(34),1,-1,1) 
     FixWhat=replace(FixWhat,"%22",chr(34),1,-1,1) 
     FixWhat=replace(FixWhat,chr(13) & chr(10),"",1,-1,1) 
     FixWhat=replace(FixWhat,"title=","alt=",1,-1,1) 
     FixWhat=replace(FixWhat,"src=" & chr(34) & chr(32),"",1,-1,1) 
     FixWhat=replace(FixWhat,"src=" & chr(34) & "/images","src=" & chr(34) & "images",1,-1,1) 
     FixWhat=replace(FixWhat,"background=" & chr(34) & chr(32),"background=" & chr(34) & chr(34) & chr(32),1,-1,1) 
     FixWhat=replace(FixWhat,"x=" & chr(34) & chr(32)," ",1,-1,1) 
     FixWhat=replace(FixWhat,"&amp;","&",1,-1,1) 
     FixWhat=replace(FixWhat,"amp;","&",1,-1,1) 
     FixWhat=replace(FixWhat,"&amp;","&",1,-1,1) 
     FixWhat=replace(FixWhat,"&&","&",1,-1,1) 
     FixWhat=replace(FixWhat,"&&","&",1,-1,1) 
     FixWhat=replace(FixWhat,"&lt;","<",1,-1,1)  
     FixWhat=replace(FixWhat,"&gt;",">",1,-1,1) 
     FixWhat=replace(FixWhat,"//<![CDATA[","",1,-1,1) 
     FixWhat=replace(FixWhat,"//]]","",1,-1,1) 
     FixWhat=replace(FixWhat,"<TABLE","<table",1,-1,1)  
     FixWhat=replace(FixWhat,"<TBODY>","<tbody>",1,-1,1) 
     FixWhat=replace(FixWhat,"<TR","<tr",1,-1,1)    
     FixWhat=replace(FixWhat,"<TD","<td",1,-1,1) 
     FixWhat=replace(FixWhat,"</TR>","</tr>",1,-1,1)    
     FixWhat=replace(FixWhat,"</TD>","</td>",1,-1,1) 

     FixWhat=replace(FixWhat,"<html><br>","<html>",1,-1,1) 
     FixWhat=replace(FixWhat,"<head><br>","<head>",1,-1,1)  
     FixWhat=replace(FixWhat,"<body><br>","<body>",1,-1,1) 
     FixWhat=replace(FixWhat,"<br><tbody>","<tbody>",1,-1,1) 
     FixWhat=replace(FixWhat,"<tbody><br>","<tbody>",1,-1,1) 
     FixWhat=replace(FixWhat,"<br><tr>","<tr>",1,-1,1) 
     FixWhat=replace(FixWhat,"<tr><br>","<tr>",1,-1,1) 
     FixWhat=replace(FixWhat,"<br><td","<td",1,-1,1) 
     FixWhat=replace(FixWhat,"<br></html>","</html>",1,-1,1) 
    end if 
    fn_dirty=FixWhat 
End Function 
%> 
0

이 문제는이 라인이 될 수 ..

Mailer.RemoteHost = "localhost" 

로컬 호스트가 전송하도록 구성되지 않은 경우/: 여기이 페이지는 이메일을 보낼 필요가있을 때마다 내 CMS 사용할 수 있도록 만든 기능입니다 해당 사용자/도메인에 대한 릴레이는 아무런 징조없이 실패 할 것입니다. 이미 youu 사이트 용으로 구성된 메일 서버가있는 경우 RemoteHost로 설정하십시오. alias.domain 또는 IP 번호를 사용할 수 있습니다.

관련 문제