469,934 Members | 2,607 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

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:

Expand|Select|Wrap|Line Numbers
  1.   <form id="pipform" enctype="text/plain" action="mailto:info@planitperfect.net?subject=Plan it Perfect" method="post" onsubmit="javascript:return validateall(this);">
  2.     <fieldset style="border:none;">
  3.     <label for="">Name:</label><br />
  4.     <input type="text" id="name" name="name" /><br />
  5.     <label for="">Email:</label><br />
  6.     <input type="text" id="email" name="email" /><br />
  7.     <label for="area">Phone:</label><br />
  8.     <input type="text" id="area" name="area" size="3" maxlength="3" /> -
  9.     <input type="text" id="first3" name="first3" size="3" maxlength="3" /> -
  10.     <input type="text" id="last4" name="last4" size="4" maxlength="4" /><br />
  11.     <label for="list">How did you hear of us?</label><br />
  12.     <select id="list" name="list" name="Hear">
  13.     <option>---------</option>
  14.     <option>Friend</option>
  15.     <option>Internet</option>
  16.     <option>Flyer</option>
  17.     <option>Wedding</option>
  18.     </select>
  19.     <br />  
  20.     <label for="inquiry">Inquiry, Comment, or Suggestion:</label><br />
  21.     <textarea id="inquiry" name="inquiry" rows="3" cols="30" name="inquiry"></textarea><br /><br />
  22.     <input type="submit" id="submit" value="Submit" />
  23.     <input type="reset" id="reset" name="reset" />
  24.     </fieldset>
  25.   </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?
Sep 7 '08 #1
7 1883
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.
Sep 8 '08 #2
533 Expert 512MB
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).

Expand|Select|Wrap|Line Numbers
  1. 'Sending SMTP mail via port 25 using CDOSYS
  2. 'This VB sample uses CDOSYS to send SMTP mail using the cdoSendUsingPort option and specifying a SMTP host.
  4. ' Note: It is recommended that all input parameters be validated when they are
  5. ' first obtained from the user or user interface.
  6. Private Sub SendMessage(strTo As String, strFrom As String)
  8. 'Send using the Port on a SMTP server
  9. Dim iMsg As New CDO.Message
  10. Dim iConf As New CDO.Configuration
  11. Dim Flds As ADODB.Fields
  12. Dim strHTML
  14. Set Flds = iConf.Fields
  16. With Flds
  17.     .Item(cdoSendUsingMethod) = cdoSendUsingPort
  18.     .Item(cdoSMTPServer) = "yourmailserver.example.com"
  19.     'Use SSL to connect to the SMTP server:
  20.     '.Item(cdoSMTPUseSSL) = True
  21.     .Item(cdoSMTPConnectionTimeout) = 10
  22.     .Update
  23. End With
  25. ' Build HTML for message body
  26. strHTML = "<HTML>"
  27. strHTML = strHTML & "<HEAD>"
  28. strHTML = strHTML & "<BODY>"
  29. strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
  30. strHTML = strHTML & "</BODY>"
  31. strHTML = strHTML & "</HTML>"
  33. With iMsg
  34.     Set .Configuration = iConf
  35.     .To = strTo
  36.     .From = strFrom
  37.     .Subject = "This is a test CDOSYS message (Sent by Port)"
  38.     .HTMLBody = strHTML
  39.     '.TextBody = "This is the text body of the message..."
  41.     .Send
  42. End With
  44. ' cleanup of variables
  45. Set iMsg = Nothing
  46. Set iConf = Nothing
  47. Set Flds = Nothing
  49. End Sub
Sample taken from MSDN.

Hope this helps.

Best regards,

Sep 8 '08 #3
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.asp", 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!
Sep 8 '08 #4
533 Expert 512MB
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.QueryString("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?message-title=Hello%20world&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,

Sep 9 '08 #5
979 Expert 512MB
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
Sep 9 '08 #6

Thanks for your help, I really appreciate it! I should be able to work this out now!
Sep 10 '08 #7
You might also want to try the mMail library found here:

http://www.virtualthinking.com/loadhtml.php?where=scripts&what=art_show.php&db_ta rget=00000000023
Oct 1 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Technical Resercher | last post: by
13 posts views Thread by Joni Nieminen | last post: by
reply views Thread by sravan_reddy001 | last post: by
4 posts views Thread by GaryDean | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.