if(mail($to,$subject,$msg,$headers)){ header("Location: http://www.mysite.com/contact/thankyou.php"); exit; }else{ $message = "Sorry, there was a problem with sending the mail."; }