Contact_Mail

This is the PHP script that sends the email for the Contact form or places up an error.

    1| <?php
    2| 
    3| function mailMode($firstName, $lastName, $email, $subject, $message, $devmode)
    4| {
    5|     $from_for_message = $firstName." ".$lastName."(".$email.")";
    6|     $from_for_mail = $firstName." ".$lastName."<".$email.">";
    7| 
    8|     if($subject == "Job Offer")
    9|     {
  10|         $to = "[EMAIL ADDRESS GOES HERE]";
  11|     }
  12|     else
  13|     {
  14|         $to = "[EMAIL ADDRESS GOES HERE]";
  15|     }
  16| 
  17|     $headers = "From: [WEBFORM@HOST.COM]\r\n";
  18|     $headers .= "MIME-Version: 1.0 \r\n";
  19|     $headers .= "Content-type: text/plain; charset=utf-8\r\n";
  20|     $headers .= "Content-Transfer-Encoding: 8bit\r\n";
  21|     $headers .= "X-Mailer: PHP/".phpversion()."\r\n";
  22| 
  23|     //back up message
  24|     mail_file($to,$from_for_mail,$subject,$message);
  25| 
  26|     $message_w_from = $from_for_message.":\n\n".$message;
  27| 
  28|     try
  29|     {
  30|         //send the message
  31|         $MessageSent = @mail($to, $subject, $message_w_from, $headers);
  32| 
  33|         if($MessageSent)
  34|         {
  35|             //Bring in header
  36|             pageHeader("../showcase/",'Contact Sucessfully Sent',0,null);
  37| 
  38|             //Bring in master head
  39|             master(4);
  40| 
  41|             echo "<div id=\"content\">\n";
  42|             echo "<h1 class=\"center\">Contact Sucessfully Sent</h1>\n";
  43|             echo "<p class=\"center\">Your message has been successfully sent.</p>\n";
  44|             echo "<a href=\"contact.php\">Return to Contact page.</a></p>\n";
  45|             echo "</div>\n";
  46| 
  47| 
  48|             //Bring in plain html code and display the ending
  49|             pageEnding("../showcase/");
  50| 
  51|         }
  52|         else
  53|         {
  54|             throw new Sent_Exception("This is a Sent Error");
  55|         }
  56|     }
  57|     catch(Sent_Exception $e)
  58|     {
  59|         //Bring in header
  60|         pageHeader("../showcase/",'Contact Message Lost',0,null);
  61| 
  62|         //Bring in master head
  63|         master(4);
  64| 
  65|         echo "<div id=\"content\">\n";
  66|         echo "<h1 class=\"center\">Contact Message Lost</h1>\n";
  67|         echo "<div class=\"error\">\n";
  68|         echo "<p>We're sorry...<br>\n We lost your message in transit.<br>\nPlease contact administrator: administrator<span class=\"webview\">{at}</span><span class=\"printview\">@</span>HOST<span class=\"webview\">{dot}</span><span class=\"printview\">.</span>com</p>";
  69|         echo "\n</div>\n";
  70|         echo "<a href=\"contact.php\">Return to Contact page.</a></p>\n";
  71|         echo "</div>\n";
  72| 
  73| 
  74|         //Bring in plain html code and display the ending
  75|         pageEnding("../showcase/");
  76| 
  77|         if($devmode)
  78|         {
  79|             $efle = $e->getFile();
  80|             $emsg = $e->getMessage();
  81|             $etrc = $e->getTraceAsString();
  82|             $Error = "Error 1030: We're sorry. We lost your message in transit.::".$efle.": ".$emsg.".|".$etrc."\n";
  83|             error_file("error",$Error);
  84|         }
  85| 
  86|     }
  87|     catch(Exception $e)
  88|     {
  89|         //Bring in header
  90|         pageHeader("../showcase/",'Contact Message Lost',0,null);
  91| 
  92|         //Bring in master head
  93|         master(4);
  94| 
  95|         echo "<div id=\"content\">\n";
  96|         echo "<h1 class=\"center\">Contact Message Lost</h1>\n";
  97|         echo "<div class=\"error\">\n";
  98|         echo "<p>We're sorry...<br>\n Something bad has happened to your message.<br>\nPlease contact administrator: administrator<span class=\"webview\">{at}</span><span class=\"printview\">@</span>HOST<span class=\"webview\">{dot}</span><span class=\"printview\">.</span>com</p>";
  99|         echo "\n</div>\n";
100|         echo "<a href=\"contact.php\">Return to Contact page.</a></p>\n";
101|         echo "</div>\n";
102| 
103|         //Bring in plain html code and display the ending
104|         pageEnding("../showcase/");
105| 
106|         if($devmode)
107|         {
108|             $efle = $e->getFile();
109|             $etrc = $e->getTraceAsString();
110|             $Error = "Error 1031: We're sorry. We lost your message in transit.::".$efle.".|".$etrc."\n";
111|             error_file("error",$Error);
112|         }
113|     }
114| }
115| 
116| ?>