0
votes

I'm making a HTML submission form and I want to have the form emailed to my email address without using a PHP script since Github Pages doesn't support it.

<form action="MAILTO:[email protected]" method = "post" enctype = "text/plain">
<p>Email Address:<input type = "text" placeholder = "Email Address:" size = "40" id="Email"></p>
<textarea rows="4" cols="50" id = "Textbox" placeholder="Enter your feeback here:"></textarea>
<p><input type="submit" value="Submit" id = "Submission"></p>
</form>

Right now, when I press submit, it will open my email client but the message I typed into the textbox does not copy over into the email message. How do I get the content of the textarea to be copied into message part of the email?

2

2 Answers

0
votes

You have to do this with javascript:
you need an a like this:

     <form id="themagicform" >
<textarea id="yourtextarea"></textarea>
       <a id="ThemagicA" href='mailto:[email protected]?subject=Me&body=textofemail'>Mail me</a>
     </form>

and then use jquery or javascript to change textofemail when they press submit:

$("themagicform").on('submit', function(){
    var hrefStr = $('themagicA').attr('href');
     var text  = $('yourtextarea').text();
    hrefStr.replace('textofemail', text);
    $('themagicA').attr('href', hrefStr);
});

Done :), hope it's works.

0
votes

In HTML you can specify a mailto: address in the <form> element's [action] attribute, The [Action] is what opens the email client the method="GET" populates the form.

<form action="mailto:[email protected]" method="GET">
    <input name="subject" type="text" />
    <textarea name="body"></textarea>
    <input type="submit" value="Send" />
</form>

What this will do is allow the user's email client to create an email and the GET will pre-populated with the fields in the <form>.