Mi codigo es asi:
Código PHP:
<?php
$submit = $_POST['submit'];
$from= $email;
$ok = false;
$name = trim($_POST['name']);
$lastname = trim($_POST['lastname']);
$email = trim($_POST['email']);
$to = $_POST['to'];
$text = $_POST['text'];
$subject = $name.' '.$lastname;
if ((isset($submit) && !empty($name)) && (!empty($lastname)) && (!empty($email)) && (!empty($to)) && (!empty($text)) && (preg_match("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]^", $email)))
{ $ok= true; }
else
{ $ok= false; }
if ($ok= true){
mail($to, $subject, $text, 'From:' .$email);
header ('Location: http://www.misitioweb.com/contact_sent.php');
} else { echo 'No se ha podido mandar el email, intente de nuevo o consulte al administrador';}
?>