Submit Contact Form without using PHP
Solution 1
You can use JavaScript to redirect to mailto:
with some parameters, but that isn't ideal. Also keep in mind that anything beyond an e-mail address in a mailto:
URL is non-standard. While it will work for many browsers, it won't work for everything.
The best way to send e-mail is to do it server-side, using PHP or something else.
Solution 2
A form is created/submitted by the browser based on HTML. JavaScript is commonly used to enhance forms (in many different ways). Basic forms send their data as a POST request. To do anything useful with the data you need server-side code to handle the POST request (such as PHP).
Solution 3
You can't submit a form to javascript and expect it to do anything. You need a server side script in order to receive a form for processing. Mailto is a browser/os specific method and is not necessarily going to invoke anything. Javscript can process your form before going to the server for further processing, but like I said you need to submit to a server.
Solution 4
Javascript cant capture anything without PHP or browser support. You need a server side script to receive a form and process it. Javascript without PHP or another server side script can't capture form.
Solution 5
You can use a service like emailjs.com:
1) Configure EmailJS:
<script type="text/javascript" src="https://cdn.emailjs.com/sdk/2.2.4/email.min.js"></script>
<script type="text/javascript">
(function(){
emailjs.init("user_USERID");
})();
</script>
2) Send the Email:
var service_id = 'my_mandrill';
var template_id = 'feedback';
var template_params = {
name: 'John',
reply_email: '[email protected]',
message: 'This is awesome!'
};
emailjs.send(service_id,template_id,template_params);
It has a limit of 200 free emails per month, which will suite a resume/portfolio website. reCaptcha is supported.
EmailJS supports different Email providers (including a custom SMTP server), and provides you with logs and statistics.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on June 17, 2022Comments
-
Admin about 2 years
I'm still a student and today our lecturer told us that the only way in order to submit a contact us form without having to use the mailto: function is to use PHP.
I swear that last year another lecturer showed us a way using only javascript.
Is it possible to submit a feedback/contact form using a basic form and javascript ? If so, do you mind sharing a sample example ?
Thanks in advance
-
Admin about 12 yearsso there is no way that the email can be sent without opening the client's default mail viewer and having them click send ?