0

How to send mail using JS and HTML?

I want to create a function which will sent e-mail, when I click "Send mail" button.

like that:

<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
       <button onclick="MyFunc()">Send mail</button>

       <script>
        function MyFunc() {
        var x=confirm("Are you sure that you want to sent mail?")
        if(x==true)
        {
        ***What to write here***
        }
        }

         </script>

    </body>
    </html>
  • 2
    Firstly, your server has to be set up to handle these kinds of requests - generally speaking, this would be impossible to do with pure javascript unless you had some kind of API set up. Otherwise, you'd do it with PHP but again - you need a mail server set up, and that's outside the scope of JS – jonny Sep 13 '15 at 09:40
  • You cannot do that client side with only html+js, you need something server side (written in nodejs, php, .net, whatever) – aghidini Sep 13 '15 at 09:40
  • Already answered in: http://stackoverflow.com/questions/7381150/how-to-send-an-email-from-javascript – BenediktasG Sep 13 '15 at 09:44

0 Answers0