I've got a feedback HTML form, the results of which I need to send to an e-mail address. How do I do that in JavaScript?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- Laravel Option Select - Default Issue
- How to toggle on Order in ReactJS
- void before promise syntax
You have two options:
1) Use a mailto link. Javascript isnt really necessary although you could use Javascript to "click" the mailto link. This will cause the user's email client to open with a new email prepopulated with the recipient's email address. mailto links There are numerous reasons why mailto links are unreliable (see comments below). They are not recommended.
2) Submit a form back to the server then send the email from the server. Whatever the server side code is (php, c# etc) should have the ability to send email. This way you can guarantee the email was sent.
You cannot silently send email from the browser. It has to either happen with user assistance or on the server.
You cannot send mails with client side javascript. Submit the form to a server side script like PHP/JSP/ASP etc and send mail from that script.
Your only option is to submit it is a regular form and then send on server side.
Impossible, for only with javascript, but with the help of server side script, you could.
Please take a look php mail function here
One way you can attempt to do this is have a
when submitting this will attempt to email the form to the given email address, this is a pretty nasty solution as it relies on the client having a correctly configured mail client. Also you have no controll over the presentation of the email. see Beware of Form Mailto Action for some of the pitfalls.