Rushabh Shah
Rushabh Shah

Reputation: 287

Email Using HTML and JavaScript

I am trying to create webpage where user can entered its detail like first name, last name, address and phone number. Once they have entered details and click on Send button it should send email to my email address and it should redirect to another page.

I am able to send email using mailto:[email protected] but it opens outlook with user details and then they need to click on send button to send email. I don't want outlook to be open and it should directly send email when they click on send button on form.

I am using JavaScript for validation and basic HTML tag to create form. Can anyone help me how to send email directly using HTML/JavaScript?

Thanks.

Upvotes: 0

Views: 793

Answers (4)

Cameron Martin
Cameron Martin

Reputation: 6012

As everyone else has said, you can't send email from the client side. However, you can use JavaScript to call a server-side script using an XMLHttpRequest, or jsonp if you're restricted by the same origin policy.

If you're new to serverside scripting, I'd suggest checking out PHP and its mail() function.

Upvotes: 0

richardhsu
richardhsu

Reputation: 878

No, it is not possible to send an email with just JavaScript and HTML, you'll need some server side code to use a mailing protocol to send it out automatically. If you have web server setup you can then a server side language like PHP to create a script to send the data, see http://php.net/manual/en/function.mail.php.

Upvotes: 1

zatatatata
zatatatata

Reputation: 4821

You can't send an email directly from client-side HTML/JS. You need to do it on the server.

Upvotes: 0

Quentin
Quentin

Reputation: 943099

There is no reliable way to send an email using client side code.

You need to submit the data to a server and process it with a server side program.

Upvotes: 0

Related Questions