I have an HTML form on my website. The form has various fields and on the submit button click i wish the data filled is sent to directly an email address. .
I am using POST method .
However when i enter the data and submit , it opens default email client (Outlook). Where as i want, that the data should be sent directly to the address is specified without opening default email client. It should be abstracted for user.
Here is my Code :
<form id="form2" method="get" class="contact_us" action="mailto:[email protected]">
<p><font face="Arial, Helvetica, sans-serif">
<label>Name
<input type="text" class="fields_contact_us" name="textfield" />
</label>
<label>E-mail
<input type="text" class="fields_contact_us" name="textfield2" />
</label>
<label>
Your message:
<textarea name="textarea" cols="" rows=""></textarea>
</label>
<label>
<input type="submit" class="submit_button_contact" name="Submit3" value="Submit" />
</label>
</font></p>
can anyone please suggest what shall be the best thing to do here ?
-
You'll not be able to do this using just HTML. You'll need something server side (PHP will probably be cheapest for you to host and there's a plethora of free resources/scripts out there) to handle the POST data and compose an e-mail. There are probably a bunch of services which'll do this for you, have a Google for something like, "email me HTML web forms" and have a shop around. I'm sure there'll be some free solutions knocking about. Best of luckSeeSharp– SeeSharp2012年01月20日 18:01:33 +00:00Commented Jan 20, 2012 at 18:01
-
My Hosting Server's info: Hosting package 500MBx800 Server Name s1 cPanel Version 11.30.5 (build 6) Theme x3 Apache version 2.0.63 PHP version 5.2.16 MySQL version 5.0.92-community Architecture x86_64 Operating system linux Shared IP Address 67.225.203.66 Path to sendmail /usr/sbin/sendmail Path to Perl /usr/bin/perl Kernel version 2.6.9-67.0.7.ELsmp cPanel Pro 1.0 (RC1)typedef1– typedef12012年01月20日 18:02:27 +00:00Commented Jan 20, 2012 at 18:02
-
typedef1, since you have PHP on there see Tim's answer below regarding the search query you can use to get a bunch of tutorials on how to achieve what you're wanting.SeeSharp– SeeSharp2012年01月20日 18:08:16 +00:00Commented Jan 20, 2012 at 18:08
-
You're using get method in the formTiago Peres– Tiago Peres2018年10月18日 21:27:48 +00:00Commented Oct 18, 2018 at 21:27
-
This question is similar to: How to send email from HTML Form. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.Nico Haase– Nico Haase2025年04月10日 07:31:14 +00:00Commented Apr 10, 2025 at 7:31
5 Answers 5
You'll need to pass it to a page with a server-side language such as php.
That page will handle the request and send the email.
Comments
If you're running a static HTML site, it may be inconvenient or challenging to run your own backend to collect form data.
There are bunch of form backend providers that you can use to collect data from your forms in the cloud and, from there, process data into email or to other systems like mailchimp, hubspot, google apps and so on.
Formkeep is one such solution.
All you would need to do is all you need to do is update the action attribute. Your form tag should look like this paying careful attention to update the underlined area of the highlighted URL with the token provided to you within FormKeep:
<form accept-charset="UTF-8" action="https://formkeep.com/f/exampletoken" method="POST">
From Formkeep you can send to email, slack or a bunch of other applications.
Comments
Using URIs with the mailto: scheme in the action attribute does not work.
You need to use an HTTP (or HTTPS) URI with a server side form handler.
You may be able to install one on your existing hosting. The specifics of how do to that will depend on which server side languages are supported, your personal preferences about those language and how the server is configured to run them.
Comments
First of all some things are incorrect in your code, for example your form uses the get method instead of post.
Furthermore you have to create some kind of backend script which is available to mail, you can use for example PHP, but their are other possibilities such as ruby, or ASP. mailto:[email protected] is simply not enough to send mail, all form fields will be pasted together and some browsers (for example opera) will not even support this action.
If you really want this add enctype="text/plain" to your form line but also old netscape browser don't know how to handle this.
Google to something like "simple PHP e-mail form" to get multiple results about how to create an email form, hope this will help you.
1 Comment
The common solution is to post the data to a server page that is capable of sending emails via SMPT.
- PHP example: http://php.net/manual/en/function.mail.php
- ASP example: http://www.tizag.com/aspTutorial/aspFormsEmail.php
Reasons it isn't so easy. I can think of two:
- There are security concerns if emails are allowed to be sent programmatically from the browser (client-side), namely, that too much information is exposed. This would be overly abused by spammers.
- Most emails are sent using TCP, which is a lower-level communication protocol than HTTP (what the browser/js is intended for). It would be akin to having a button on an ATM machine for buzzing the bank manager.