1

I'm trying to make a web-app where one submits a form, and it sends the results of the form to an email (my email, at first). I've tried many different things using HTML forms, but none seem to work.

This was from a form example source code that I was trying to use, just for email sending. I think the problem is the action link is registered to the place I got it from, or something like that, and/or I'm not sure what to put in the first and fourth line.

<form method="POST" action="http://public.registerdirect.co.nz/cgi-bin/formmailer.cgi">
<input type="hidden" name="to" value="email@mydomain.co.nz">
<input type="hidden" name="subject" value="The Message Subject">
<input type="hidden" name="next_url" value="http://www.mysite.co.nz/thankyou.html">
<input type="text" name="comments">
</form> 

How do I send the results of a form to someone's email?

I've heard that you need to use a side-server, but I can't figure that out either.

  • Basically it can't be done with javascript. You need to use a severside technology to do this: ASP.net, PHP, etc. In the code you have provided `action="http://public.registerdirect.co.nz/cgi-bin/formmailer.cgi"` points to a serverside script which handles the emailing – Jon P Aug 05 '14 at 00:08

2 Answers2

0

To send the contents of a form to an email address, use MAILTO in the form's action, like this (use your own email address):

<form action="MAILTO:someone@example.com" method="post" enctype="text/plain">

Leave the rest of the form as it is, and make sure you've named all of the field in the form. Check out this example if you like.

If you want to use php to send the email, you can check out this tutorial.

Hope this helps!

Eoin
  • 833
  • 2
  • 13
  • 24
  • Note, this won't actually send the email. It will open up the users email client to enable them to create an email. – Jon P Aug 05 '14 at 00:10
  • Thank you. I looked at that when I was trying to figure things out I think. I tried it again. And I've tried the mail to thing. I replace my email with the example one, and yet it doesn't send me an email nor does it open the email client. so I'm not sure what the problem is. I'll try this on a different computer to see if it's a problem with mine. – user3822190 Aug 05 '14 at 00:13
  • @Jon P Yes, but it's the best we can do without using server-side code! He did specify HTML and javascript in the title. – Eoin Aug 05 '14 at 00:16
  • Yes he also mentioned sending the email, which this does not do. – Jon P Aug 05 '14 at 00:17
  • @user3822190 Have you set a default email client? The form opens Outlook with no problems for me... – Eoin Aug 05 '14 at 00:18
  • @Eoin Why do you assume I'm a guy? [insert gif of Beyonce running the world here] Thanks for all your help! – user3822190 Aug 05 '14 at 20:38
0

As Jon P said, you have to check first how does the service provided by "registerdirect.co.nz" works. If you don't want to use their service, then you can create a PHP (or any server side language) script to process that information and to use an SMTP server (like gmail) to send the email (check: Send email using the GMail SMTP server from a PHP page)

Community
  • 1
  • 1
lepe
  • 24,677
  • 9
  • 99
  • 108