SOunds like you need to validate the form and then send it to a server wich then revalidates (javascript can not be thrusted) and sends the mail-request to an e-mail server.
I'd recommend PHP for the server that revalidates the form and sends the request to the e-mail server because it's easy and wide supported.
Say you have this HTML
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="script.js"></script>
<form id="emailForm" method="post" action="mail.php">
<input type='text' name='firstName' id="firstName"><br>
<input type='text' name='lastName' id='lastname'><br>
<input type='submit' value='submit' name='submit'>
</form>
You could verify that the user entered something in all fields using javascript and jQuery.
Say in the file script.js you have:
var formIsOkay = true;
$(document).ready( function() {
$('#emailForm').submit( function() {
$('#emailForm input').each( function() {
if ( this.val() == '' ) { formIsOkay = false; }
}
return formIsOkay;
}
}
And then in email.php you would have something like this:
<?php
$to = '[email protected]';
$from = '[email protected]';
$subject = 'Form';
$message = 'Hello, the following variables were supplied:<br>';
foreach($_POST as $key => $val){
$message .= "$key = $val<br>";
}
$message = wordwrap($message, 70);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "To: $to" . "\r\n";
$headers .= "From: $from" . "\r\n";
mail($to, $subject, $message, $headers);
?>
You will need PHP running on your server for this, and an SMTP server setup in php, but most servers have this.
Note btw how PHP does not reavlidate the form right now so when someone submits an empty form it will still be send in the e-mail.