Search code examples
htmlcssemailmailto

How do I make an email form in html that allows users to type a message then, in a new window, prompts them to send the message?


I want the user to input the message they want to send in a form, but after they click send, it brings up their email for them to send.

The only reason for this is because I don't have a server.

Is this possible?

Thanks


Solution

  • According to this question, you can do it with Javascript:

    function sendMail() {
        var link = "mailto:me@example.com"
                 + "?cc=myCCaddress@example.com"
                 + "&subject=" + escape("This is my subject")
                 + "&body=" + escape(document.getElementById('myText').value)
        ;
    
        window.location.href = link;
    }
    <textarea id="myText">Lorem ipsum...</textarea>
    <button onclick="sendMail(); return false">Send</button>