Kod çalışmıyor - email gitmiyor ve anasayfaya dönüyor GÖNDERe basınca. Hata uyarısınıda göstermiyor ekranda.

<?php
 
session_start();

include ("ayar.php");

$action = $_GET[action];

if ($action == 'sendemail') {
    $sendSubject = $_POST[messagesubject];
    $sendMessage = $HTTP_POST_VARS['message'];
    $sendName = $_POST[sendername];
    $sendEmail = $_POST[senderemail];
    if (!empty($sendMessage)) {
      if (preg_match(' /[\r\n,;\'"]/ ', $sendEmail)) {
          header ("Location: ".$siteurl."/irtibat.php?e=1");
          exit();
      } else {
          mail($sitecontactemail, $sendSubject, $sendMessage, "From: " .$sendName. "<".$sendEmail.">\nReply-To: ".$sendEmail. "\nX-Mailer: PHP.ee/". phpversion()); 
          header ("Location: ".$siteurl."/irtibat.php?e=2");
          exit();
      }
    } else {
        header ("Location: ".$_SERVER['HTTP_REFERER']);
        exit();
    }
} else {
    $contactError = $_GET[e];
    if ($contactError == '1') {
        $contactErrorText = "Geçersiz email adresi";
    } elseif ($contactError == '2') {
        $contactErrorText = "Tesekkürler , mesajınız başarıyla yollandı.";
    } else {
        $contactErrorText = "";
    }
    $sitename2 = $sitename." - irtibat";


    include ("template/".$template."/top.html");
    include ("template/".$template."/irtibat.html");
    include ("template/".$template."/bottom.html");
}

?>