Forum email send with ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SAF22
    New Member
    • Aug 2008
    • 6

    Forum email send with ASP

    Hi guys,

    I'm a pretty basic coder with very limited skills. I've been researching this question everywhere and I can't find anything that works.

    What I'm trying to do is simply send a form which is filled out on their webpage, to their email address. Currently I am using a mailto: function which I desperately want to avoid. Also, if it helps this site is hosted through godaddy (windows package), if that makes any difference. Here is the HTML for my form:

    Code:
      <form id="pipform" enctype="text/plain" action="mailto:info@planitperfect.net?subject=Plan it Perfect" method="post" onsubmit="javascript:return validateall(this);">
        <fieldset style="border:none;">
        <label for="">Name:</label><br />
        <input type="text" id="name" name="name" /><br />
        <label for="">Email:</label><br />
        <input type="text" id="email" name="email" /><br />
        <label for="area">Phone:</label><br />
        <input type="text" id="area" name="area" size="3" maxlength="3" /> -
        <input type="text" id="first3" name="first3" size="3" maxlength="3" /> -
    	<input type="text" id="last4" name="last4" size="4" maxlength="4" /><br />
        <label for="list">How did you hear of us?</label><br />
        <select id="list" name="list" name="Hear">
        <option>---------</option>
        <option>Friend</option>
        <option>Internet</option>
        <option>Flyer</option>
        <option>Wedding</option>
        </select>
        <br />  
        <label for="inquiry">Inquiry, Comment, or Suggestion:</label><br />
        <textarea id="inquiry" name="inquiry" rows="3" cols="30" name="inquiry"></textarea><br /><br />
        <input type="submit" id="submit" value="Submit" />
        <input type="reset" id="reset" name="reset" />
        </fieldset>
      </form>
    I've tried a few different options, but when it sends I usually get something like "post not allowed for request.asp."

    So I'm pretty stuck, any help would be appreciated. At least a push in the right direction?
  • SAF22
    New Member
    • Aug 2008
    • 6

    #2
    Also, I forgot to mention the form is already validated through JavaScript. Plus if it helps, I also tried doing this send through PHP which I later found out isn't supported by the web host.

    Comment

    • JamieHowarth0
      Recognized Expert Contributor
      • May 2007
      • 537

      #3
      Hi SAF22,

      Firstly, welcome to Bytes IT Community!

      Secondly, you can either use ASP or PHP mail functions (depending on whether your GoDaddy host account supports it). It simply involves setting your form method to POST, then setting the action attribute on the form to the script that will send the mail for you.

      In ASP, the easiest way to send mail is using the Windows controls CDO/CDOSYS (on Windows Server 2003) or CDONTS (on NT4/Win2K systems).

      [code=asp]
      'Sending SMTP mail via port 25 using CDOSYS
      'This VB sample uses CDOSYS to send SMTP mail using the cdoSendUsingPor t option and specifying a SMTP host.

      ' Note: It is recommended that all input parameters be validated when they are
      ' first obtained from the user or user interface.
      Private Sub SendMessage(str To As String, strFrom As String)

      'Send using the Port on a SMTP server
      Dim iMsg As New CDO.Message
      Dim iConf As New CDO.Configurati on
      Dim Flds As ADODB.Fields
      Dim strHTML

      Set Flds = iConf.Fields

      With Flds
      .Item(cdoSendUs ingMethod) = cdoSendUsingPor t
      .Item(cdoSMTPSe rver) = "yourmailserver .example.com"
      'Use SSL to connect to the SMTP server:
      '.Item(cdoSMTPU seSSL) = True
      .Item(cdoSMTPCo nnectionTimeout ) = 10
      .Update
      End With

      ' Build HTML for message body
      strHTML = "<HTML>"
      strHTML = strHTML & "<HEAD>"
      strHTML = strHTML & "<BODY>"
      strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
      strHTML = strHTML & "</BODY>"
      strHTML = strHTML & "</HTML>"

      With iMsg
      Set .Configuration = iConf
      .To = strTo
      .From = strFrom
      .Subject = "This is a test CDOSYS message (Sent by Port)"
      .HTMLBody = strHTML
      '.TextBody = "This is the text body of the message..."

      .Send
      End With

      ' cleanup of variables
      Set iMsg = Nothing
      Set iConf = Nothing
      Set Flds = Nothing

      End Sub
      [/code]
      Sample taken from MSDN.

      Hope this helps.

      Best regards,

      medicineworker

      Comment

      • SAF22
        New Member
        • Aug 2008
        • 6

        #4
        Thank you for the welcome medicineworker!

        So, what I did was take that code and placed it onto an .asp page (called test.asp). I changed my form action to action="test.as p", and set method to post (which it already was). I am not too sure what is going on with the script, but I wanted to see if I could at least get some kind of positive response . What happened is the same thing with the PHP actually. Here is what happens after the submit button:

        Method POST is not allowed by /test.asp

        This sounds to me like the web server isn't allowing ASP as well as PHP. Is this the case, or am I way off?

        I'm very sorry, please bare with me as I am extremely new to this language. I have done some research on it and getting the feel for it, but still far from understanding!

        Comment

        • JamieHowarth0
          Recognized Expert Contributor
          • May 2007
          • 537

          #5
          Hi there,

          Yes, that sounds about right. It would appear that your web server refuses to accept HTTP POST requests for most, if not all, server-side languages. If this is a third-party host then you need to speak to them to see if they will relax the ASP permissions. If they won't, then use the GET method instead, and change the code to get Request.QuerySt ring("my-form-field-name") instead.

          FYI (a little background) - every time you request a page, an HTTP request is made, using one of two methods - GET or POST. GET simply requests the requested URL from the server, and any additional data is submitted as a querystring (e.g. test.asp?messag e-title=Hello%20w orld&message-body=This%20is% 20a%20test) - notice the way it's encoded so even spaces can be transmitted safely.
          POST sends data WITH the request, in the headers, and is therefore "invisible" to the user. POST carries security issues for third-party hosting companies as they suspect every file upload is a virus that will bring down their server farm!

          In this instance, unless you have a specific reason to use POST (secure, confidential messages) then simply switch to GET, it GET's you round the problem (gotta love my puns!)

          Best regards,

          medicineworker

          Comment

          • DrBunchman
            Recognized Expert Contributor
            • Jan 2008
            • 979

            #6
            Originally posted by medicineworker
            it GET's you round the problem (gotta love my puns!)
            You've got to love that kind of punning! Keep 'em coming...

            Dr B

            Comment

            • SAF22
              New Member
              • Aug 2008
              • 6

              #7
              Hahaha.

              Thanks for your help, I really appreciate it! I should be able to work this out now!

              Comment

              • dlynx
                New Member
                • Oct 2008
                • 3

                #8
                You might also want to try the mMail library found here:

                http://www.virtualthin king.com/loadhtml.php?wh ere=scripts&wha t=art_show.php& db_target=00000 000023

                Comment

                Working...