For goodness sake: no JavaScript, no client-side. You can do it reliably and safely only using some server-side technology: ASP.NET, Python with WSGI, PHP after all. On the client side you only need a form with data needed for a mail, it should use the HTTP method "POST". The server side should get the posted data and send a message based on it.
A big warning! You should not send data, especially headers as is. Programmatically, it's way too easy to turn your server into a zombie sending spam if not worse. Filter our anything suspicious from headers, all non-printing characters, HTML or script codes, etc. If such thing happens, log the information about the even as an attempt of malicious activity and investigate such cases. It happens too often.
[EDIT]
Here is my recent article explaining the exploit in more detail:
unable to send mail , it showing the error in below code .[
^].
Take care!
[END EDIT]
And forget JavaScript and client-side. This way, you make it completely open for malicious activity. Also, you cannot assume any particular software installations on the user's client system. Just forget the idea.
—SA