<form id="form" action="" method="post" accept-charset="utf-8" />
<input type="text" name="name" value="" placeholder="Ваше имя" />
<input type="email" name="email" value="" placeholder="Ваш е-мейл" />
<textarea name="text" rows="8" cols="40" placeholder="Сообщение">
</textarea>
<button type="submit">Отправить</button>
</form>
if(isset($_POST['submit'])) {
if(trim($_POST['contactname']) == '') {
$hasError = true;
} else {
$name = trim($_POST['contactname']);
}
if(trim($_POST['subject']) == '') {
$hasError = true;
} else {
$subject = trim($_POST['subject']);
}
if(trim($_POST['email']) == '') {
$hasError = true;
} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
$hasError = true;
} else {
$email = trim($_POST['email']);
}
if(trim($_POST['message']) == '') {
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['message']));
} else {
$comments = trim($_POST['message']);
}
}
if(!isset($hasError)) {
$emailTo = 'name@yourdomain.com'; //Сюда введите Ваш email
$body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments";
$headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
}