How to send to a specific email using Javascript forms? -


i want have can fill out kind of form (below) , when click "send" send specific email have inputted. meaning, declaring information filled out in "email" field variable , somehow have "mailto:" link send email address. hope makes sense. i'm not entirely sure how explain it.

it seems relatively simple, i'm not having luck (javascript not strongest language).

<!doctype html> <html> <body>  <h2>send e-mail someone@example.com:</h2>  <form action="mailto:someone@example.com" method="post" enctype="text/plain"> name:<br> <input type="text" name="name" value="your name"><br> e-mail:<br> <input type="text" name="mail" value="your email"><br> comment:<br> <input type="text" name="comment" value="your comment" size="50"><br><br> <input type="submit" value="send"> <input type="reset" value="reset"> </form>  </body> </html> 

or, way make contact form of sorts, goes email input somewhere in form.

the mailto can't used form directly.

however, can :

<!doctype html> <html> <head> <script src="http://code.jquery.com/jquery-2.1.4.js"></script> </head> <body>  <h2>send e-mail someone@example.com:</h2>  <form action="#" id="myform"> name:<br> <input type="text" name="name" value="your name"><br> e-mail:<br> <input type="text" name="mail" value="email@mail.com"><br> comment:<br> <input type="text" name="comment" value="your comment" size="50"><br><br> <button id="btnsend">send mail</button> <input type="reset" value="reset"> </form> <script> $(function(){     $(myform).submit(function(){     var mailto = "mailto:";      mailto += $("input[name=mail]").val();      mailto += "?subject=your email subject (new comment)";      mailto += "&body=message : " + $("input[name=name]").val() + " comment : " + $("input[name=comment]").val();     console.log(mailto);     window.open(mailto);     return false;     });  }); </script> </body> </html> 

basicly agregate field value , opend new windows/tab mailto url.

note open mail client of user (if he/she have one) , he/she have click send mail go.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -