Internal Server Error to send Form

2019-09-10 04:33发布

Please Helpme, i have this error, when I send the contact form :

enter image description here

My Visual Basic code:

<%
mail_to = "jrclurita@gmail.com"

Dim error
error = 0
For Each f In Request.Form
  If Request.Form(f) = "" Then
    error = 1
  End If
Next
If error=1 Then
  response.redirect "error.html"
Else
Dim f, emsg, mail_to, r, o, c, other
fline = "_______________________________________________________________________"& vbNewLine  
hline = vbNewLine & "_____________________________________"& vbNewLine  
emsg = ""

For Each f In Request.Form
   If mid(f,1,1)<>"S"  = True Then 'do not save if input name starts with S
     emsg  = emsg & f & " = " &  Trim(Request.Form(f)) & hline
   End If
Next

Set objNewMail = Server.CreateObject("CDONTS.NewMail")
        objNewMail.From = Request("Email Address")
        objNewMail.Subject = "Message from contact page (version: 1.0)"
        objNewMail.To = mail_to
        objNewMail.Body = emsg & fline
        objNewMail.Send
        Set objNewMail = Nothing

response.redirect "thankyou.html"
End if
%>

And my html code of my form:

<html>

    <head>
    <title>Formulario Contacto</title>
    </head>

    <body>

    <form method="POST" action="contactusprocess.asp">
      <table>
        <tr>
          <td>Nombres y Apellidos:</td>
          <td><input name="Name" size="25" maxlength="50"></td>
        </tr>
        <tr>
          <td>Email:</td>
          <td><input name="Email Address" size="25" maxlength="50"></td>
        </tr>
        <tr>
          <td>Telefono o Celular:</td>
          <td><input name="Telephone No" size="25" maxlength="50"> </td>
        </tr>
        <tr>
          <td valign="top">Mensaje:</td>
          <td><textarea cols="24" name="Message" rows="6"></textarea> </td>
        </tr>
        <tr>
          <td colspan="2">
            <div align="center">
              <center>
                <p>
                  <input type="submit" value="Enviar" name="Submit">
                </p>
              </center>
            </div>
            <div align="center"><center>        
          </td>
        </tr>
      </table>
    </form>
    </body>
    </html>

Mi Server is Godaddy Windows IIS

My web.config File:

<?xml version="1.0" encoding="utf-8"?>
<!--
  Para obtener más información sobre cómo configurar la aplicación de ASP.NET, visite
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <customErrors mode="Off" />
    <pages validateRequest="false" />
    <globalization culture="es-PE" uiCulture="es-PE" />
    <trust level="Low" />
  </system.web>
</configuration>

Please, two days I can not find a solution.

1条回答
聊天终结者
2楼-- · 2019-09-10 05:26

While the CDONT method requires IIS server configuration for a mail server, the CDO method does not as it allow you to specify the outgoing mail server, port, etc as you build each message. Here is a sample framework for a text message using the CDO library reference.

<%
    Set cdoMail = CreateObject("CDO.Message")

    sFROM = "your_email@gmail.com"
    sFROMPWD = "XXXXXX"
    sEML = "someone@somewhere.com"
    sATTCH = "c:\temp\hello_world.txt"

    On Error Resume Next
    With cdoMail
        With .Configuration.Fields
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2   'cdoSendUsingPort
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1    'cdoBasic
            .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = sFROM
            .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sFROMPWD
            .Update
        End With
        .From = sFROM
        .To = sEML
        '.CC = ""
        '.BCC = ""
        .Subject = "Test Mail"
        .HTMLBody = "<html><body><p>Mailtest.</p></body></html>"
        '.AddAttachment sATTCH
        .send

        'response.write Err.Number & " - " & Err.Description
        'Err.Clear
    End With

    set cdoMail = nothing

%>

I've commented out some of the fields that you may find interesting. I just ran that on my IIS7 box (with valid credentials factored in) and it processed without a hitch.

查看更多
登录 后发表回答