title: PHP mail Function Not Working Properly With Form
body: <p>I'm having endless troubles creating a contact form in PHP. </p>
  
  <p>I first tried the method to write the data (as outlined in the question here: <a href="https://stackoverflow.com/questions/8771486/html-form-not-outputting-to-csv-file-or-displaying-correct-error-messages">HTML Form Not Outputting To CSV File (Or Displaying Correct Error Messages)</a>) and now I'm just trying the method of sending the info in an e-mail to myself.</p>
  
  <p>Here's my jsfiddle:</p>
  
  <p><a href="http://jsfiddle.net/tqs6g/1/" rel="nofollow noreferrer">http://jsfiddle.net/tqs6g/1/</a></p>
  
  <p>Here's the PHP I've written to send the info to myself (I understand it's not very elegant coding but I just want to get something to work first and then I was going to use arrays, etc.):</p>
  
  <pre><code>&lt;?php
  
  if (isset($_POST['brandname']) &amp;&amp; isset($_POST['firstname']) &amp;&amp; isset($_POST['lastname']) &amp;&amp; isset($_POST['email']) &amp;&amp; isset($_POST['website'])){
      $brandname = $_POST['brandname'];
      $firstname = $_POST['firstname'];
      $lastname = $_POST['lastname'];
      $email = $_POST['email'];
      $website = $_POST['website'];
  
      if(!empty($brandname) &amp;&amp; !empty($firstname) &amp;&amp; !empty($lastname) &amp;&amp; !empty($email)){
          $to = 'myemail@example.com';
          $subject = 'Submission Form';
          $body = $firstname;
          $headers = 'From: '.$email;
  
          if (@mail($to, $subject, $body, $headers)){
              echo 'Yeah yeah';
              }else{
                  echo 'yeah no.';
                  }
  
          }else{
          echo 'Please fill out all required fields.';
          }
  
      }
  ?&gt;
  </code></pre>
  
  <p>The e-mail I used in this example is obviously not my e-mail (I use my real one in my code). Basically what happens is I fill out the form and hit submit and it reloads the form.php page. I check my e-mail and nothing has come through. If I check the source code for the site the words 'Yeah yeah.' show up in the code (from where it echos out when it successfully sends the e-mail). So the code seems to be running properly but it's not outputting anything.</p>
  
  <p>Do I have to set up some mail servers/functions through my localhost?</p>
  
  <p>What am I missing out on?</p>