If you are using Asp.Net then use Javascript Ajax postback and send email from server side. You can achieve this using XmlHttpObject or JQuery. In case you are working on pure HTML and Javascript application then try SendGrid REST API. Below is SendGrid website url.
http://sendgrid.com/documentation/display/api/Web[
^]
Sample code is like below.
<script language="javascript" type="text/javascript">
function Sendmail() {
if (document.getElementById("TxtFrom").value == "" || document.getElementById("TxtTo").value == "" || document.getElementById("TxtSub").value == "" || document.getElementById("TxtBody").value == "") {
alert("Fields cant not be empty!");
}
else {
var restURL = "https://sendgrid.com/api/mail.send.xml?api_user=UserRegistrationEmail@domain.com&api_key=ApiKeyValue&to=" + document.getElementById("TxtTo").value + "&toname=Destination&subject=" + document.getElementById("TxtSub").value + "&html=" + document.getElementById("TxtBody").value + "&from=" + document.getElementById("TxtFrom").value;
window.open(restURL, 'sendgrid', 'width=400,height=200');
//window.location.href = maill;
alert("Mail sent successfully!");
}
}
</script>