2

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:myemail@gmail.com">
<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 ?

typedef1
  • 247
  • 2
  • 6
  • 14
  • 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 luck – SeeSharp Jan 20 '12 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 Jan 20 '12 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 Jan 20 '12 at 18:08
  • You're using get method in the form – Tiago Martins Peres Oct 18 '18 at 21:27

5 Answers5

3

You'll need to pass it to a page with a server-side language such as .

That page will handle the request and send the email.

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
1

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.

0

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.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

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:myemail@gmail.com 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.

Tim
  • 9,351
  • 1
  • 32
  • 48
  • The thing is i have configured it using Google docs form. But only issue is i have to use form created by google. Rather i wish to use my own form – typedef1 Jan 20 '12 at 18:35
0

The common solution is to post the data to a server page that is capable of sending emails via SMPT.

Reasons it isn't so easy. I can think of two:

  1. 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.
  2. 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.
calebds
  • 25,670
  • 9
  • 46
  • 74