title: PHP object oriented contact form
body: <p>My contact form is not willing to send an Email. No errors are given, but no mail is received either (I'm not working on a local server).</p>
  
  <p>I'm using the Object Oriented way, not the easiest way, still it should work.. My guess is that the mail() function isn't triggered at all, but I don't understand why.</p>
  
  <p>All help is deeply appreciated!</p>
  
  <p><strong>contact.php</strong></p>
  
  <pre><code>&lt;?php
  
  include_once('classes/sendmail.php');
  
  if(isset($_POST['sendmessage'])){
      try {
          $e = new Email();
          $e-&gt;Name = $_POST['name'];
          $e-&gt;Email = $_POST['email'];
          $e-&gt;Message = $_POST['message'];
          $e-&gt;Send();
      }
  
      catch(Exception $e){
          $error = $e-&gt;getMessage();
      }
  }
  
  if(isset($error)){
      echo $error;
  }
  ?&gt;
  
  
  &lt;!doctype html&gt;
  &lt;body&gt;
  
  
              &lt;form name="contactform" action="" method="post" enctype="text/plain"&gt;
                      &lt;label for="name"&gt;Name&lt;/label&gt;
                      &lt;input type="text" name="name" id="name" class="name" /&gt;
  
                      &lt;label for="email"&gt;E-mail&lt;/label&gt;
                      &lt;input type="text" name="email" id="email" class="email" /&gt;
  
                      &lt;label for="message"&gt;Message&lt;/label&gt;
                      &lt;textarea id="message" name="message" &gt;&lt;/textarea&gt;
  
                  &lt;input type="submit" class="send" value="Verzend" name="sendmessage" /&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p><strong>classes/sendmail.php</strong></p>
  
  <pre><code>&lt;?php
  
  class Email{
  
      private $m_sName;
      private $m_sEmail;
      private $m_sMessage;
  
      public function __set($p_sProperty, $p_vValue){
          switch($p_sProperty){
  
              case 'Name':
                  if($p_vValue != '') {
                      $this-&gt;m_sName = $p_vValue;
                  }
                  else{
                      throw new Exception("No name found");
                  }
                  break;
  
              case 'Email':
              if($p_vValue != '') {
                      $this-&gt;m_sEmail = $p_vValue;
                  }
                  else{
                      throw new Exception("No email adress found");
                  }
                  break;
  
              case 'Message':
                  if($p_vValue != '') {
                      $this-&gt;m_sMessage = $p_vValue;
                  }
                  else{
                      throw new Exception("No message found");
                  }
                  break;
          }
      }
  
      public function __get($p_sProperty){
          switch($p_sProperty){
              case 'Name':
                  return $this-&gt;m_sName;
                  break;
  
              case 'Email':
                  return $this-&gt;m_sEmail;
                  break;
  
              case 'Message':
                  return $this-&gt;m_sMessage;
                  break;
          }
      }
  
      public function Send(){
  
          $email_to = "&lt;my Email&gt;";
          $email_subject = "&lt;my subject&gt;";
  
          $email_message = "Name: ".$this-&gt;m_sName."\n";
          $email_message .= "Email: ".$this-&gt;m_sEmail."\n";
          $email_message .= "Message: ".$this-&gt;m_sMessage."\n";
  
          $headers = 'From: '.$this-&gt;m_sEmail."\r\n".
          'Reply-To: '.$this-&gt;m_sEmail."\r\n" .
          'X-Mailer: PHP/' . phpversion();
  
          mail($email_to, $email_subject, $email_message, $headers);
  
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>Edit: A lot of questions were already asked about contact forms, yet no one that used OOP seemed to have the same problem as I did. </p>