If you really can't use PHP, you can use the formmail.cgi if your host provides one. Most hosts support this, and instructions for using FormMail are simple.
This is trivial if you are using PHP though. You can try to rename the page with a .php extension (instead of .htm or .html) and put the following code into your page:
<div class="post">
<h2 class="title">Write to us</h2>
<?php
function validEmail($email)
{
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex)
{
$isValid = false;
}
else
{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64)
{
// local part length exceeded
$isValid = false;
}
else if ($domainLen < 1 || $domainLen > 255)
{
// domain part length exceeded
$isValid = false;
}
else if ($local[0] == '.' || $local[$localLen-1] == '.')
{
// local part starts or ends with '.'
$isValid = false;
}
else if (preg_match('/\\.\\./', $local))
{
// local part has two consecutive dots
$isValid = false;
}
else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
{
// character not valid in domain part
$isValid = false;
}
else if (preg_match('/\\.\\./', $domain))
{
// domain part has two consecutive dots
$isValid = false;
}
else if(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
str_replace("\\\\","",$local)))
{
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/',
str_replace("\\\\","",$local)))
{
$isValid = false;
}
}
if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A")))
{
// domain not found in DNS
$isValid = false;
}
}
return $isValid;
}
if (isset($_REQUEST['email']))
{//if "email" is filled out, proceed
//check if the email address is invalid
$mailcheck = validEmail($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "<p>Invalid e-mail address.</p>";
}
else {
//send email
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail("recepient@example.com", "Subject: Message from contact form",
$message, 'From: "' . $name . '" <' . $email . '>' );
echo "<p>Thank you for writing to our website. Please allow up to 24 hours for a reply, if you have requested one.</p>";
}
}
else {
//if "email" is not filled out, display the form
echo "<form method='post' action='contact.php'>
Name: <input id='name' name='name' type='text' /><br />
E-mail: <input id='email' name='email' type='text' /> (required)<br />
Message for us:<br />
<textarea id='message' name='message' rows='15' cols='40'>
</textarea><br />
<input id='submit' type='submit' value='Send Message' />
</form>";
}
?>
</div>