Send email with php
<p>Hi I have validated a form with php but something seems to be wrong in the code.After validating it should send an email ,but it doesn't.Here is my code:</p>

<pre><code>  $firstName = $_POST["firstName"];
$lastName = $_POST["lastName"];
$email = $_POST["email"];
$message = $_POST["message"];
$to = "fox.team001@gmail.com";
$subject = $firstName . " " . $lastName;
$headers = "From: fox.team001@gmail.com\r\nReply-To: fox.team001@gmail.com";

validate($firstName , $lastName , $email , $message);

function validate ($firstName , $lastName , $email , $message){
    if(!empty($firstName) &amp;&amp; !empty($lastName)  &amp;&amp; !empty($email) &amp;&amp; !empty($message)){
        if(validateEmail($email)){
            $mail_sent = @mail($to , $subject , $message , $headers);
            header('refresh:5;url=http://www.foxteam.net');
        }else{
           header('refresh:0;url=http://www.foxteam.net/contact.php');
        }
    }else{
        header('refresh:0;url=http://www.foxteam.net/contact.php');
    }
}

function validateEmail($email) {
    $pattern = "^[A-Za-z0-9_\-\.]+\@[A-Za-z0-9_\-]+\.[A-Za-z0-9]+$";
    if(preg_match("/{$pattern}/", $email)) {
        return true;
    }else{
        return false;
    }
}
</code></pre>
