admin管理员组

文章数量:1401611

I’ve been trying to figure out how to submit form data without using PHP code, is there a way? The mailto: in HTML 5 only has the user fill the form out, then when submit is clicked, it opens another application (mail app on desktop/laptop, and mail app on smartphones) and puts the data fields inside the message and makes the user click send in their mail, what do I do to at least just make the email sent to my email without the user having to take extra steps? Or being redirected to another app?

I’ve been trying to figure out how to submit form data without using PHP code, is there a way? The mailto: in HTML 5 only has the user fill the form out, then when submit is clicked, it opens another application (mail app on desktop/laptop, and mail app on smartphones) and puts the data fields inside the message and makes the user click send in their mail, what do I do to at least just make the email sent to my email without the user having to take extra steps? Or being redirected to another app?

Share Improve this question edited Jun 2, 2019 at 17:42 Ramesh 2,4032 gold badges24 silver badges44 bronze badges asked Jun 2, 2019 at 15:49 RJLYSSRJLYSS 331 silver badge5 bronze badges 5
  • you don't have to use php for the form submission. You could even use JS for submitting a form. And the mailto haven't anything to do with a form submission. – Sumithran Commented Jun 2, 2019 at 16:01
  • You can use EmailJs or SMTPJs to sent the email using javascript. emailjs./docs/sdk/installation , smtpjs. – Jijin P Commented Jun 2, 2019 at 16:02
  • this is what you are looking for stackoverflow./a/36656479/7796787 – Amospikins Commented Jun 2, 2019 at 16:08
  • 1 It would be better if you explain what you want to acplish by doing this. It sounds you are trying to avoid using a server to process the data. – Juan Commented Jun 2, 2019 at 16:08
  • maybe this is what you want stackoverflow./questions/4782068/… – Abed Putra Commented Jun 2, 2019 at 16:22
Add a ment  | 

2 Answers 2

Reset to default 4

If I understand correctly, I think you can do the following. Grab the values of the inputs through javascript and send the email using window.location with the input values.

HTML

<input type="text" id="subject">
<textarea id="body"></textarea>
<button type="button" id="send">Submit</button>

JS

$('#send').on('click', function(e) {
  e.preventDefault();
  subject = $('#subject').val();
  body = $('#body').val();
  window.location = "mailto:[email protected]?subject=" + subject + "&body=" + body;
});

HTML's mailto process will prompt the user's mail service (outlook, thunderbird, etc.) to open, but none of your form data will be "processed". So, that might not be the best solution for you.

  1. mailto doesn't respond in exactly the same way for every browser and every email client.
  2. Using this method allows your site visitor to send any information they want to you just by editing the email before they send it to you.
    Example: I fill out your form and hit the send (or submit) button. My mail client (Thunderbird) opens with all of the address to, from, subject, and message fields already filled in. I erase the message field and put in "something else". Then I send it to you. You open your email and ...
  3. You are providing your email address to a gazillion webcrawlers who scrub the internet for email addresses to send scams, junk, etc. to on a daily basis.

submit form data without using PHP code

The primary purpose of your script is to process the information before it's sent. The script will parse the data, removing information bits that are ordinarily used in programming. Like, potential Malware code. A form/email script (like this) can be written in any language that will municate directly with the server (provided that the language is on the hosting server)... PHP, CGI/Perl, (maybe javascript?), etc.

What you are looking to do, is match the values in your form to the users answers and then relay that informaiton. In order to do that, you will want to first create your form. When your site visitor fills out the form and hits submit, you want the data to be sent to a script which will check the data, then plete the email fields (to, from, subject, message) and then send it through the server (without exposing your email address to the world).

This is probably a task for an intermediate programmer. That doesn't mean that a "Noob" can't do it, just that it will require a bit of learning to get there. Compare examples online until you find one that makes sense to you.

本文标签: javascriptForm submit without PHPStack Overflow