title: Debugging PHP email form
body: <p>I have been trying to set up a simple form on my website that sends an email to my inbox (not the website visitor's) with email address that the visitor enters into the form.  It isn't very complicated, but as I am testing, I can't seem to get any email address to work.  I don't get any error message either.  I will paste the code below.</p>
  
  <p>At the very least, I'd like to know if there could be a problem with the DNS or host configurations.  This is my first time building a website, so I'm unsure if the problem is in the code, the HTML (a separate file not pasted here), or the server or host settings.</p>
  
  <p>To make matters more difficult, I have once gotten an error message along the lines of something not configured properly, but I can't seem to get the error message anymore.  I don't think I changed any code.  That makes me suspect there may be something else going on server-side.  Is that feasible?</p>
  
  <p>Thanks in advance for taking a peek.</p>
  
  <pre><code>&lt;?php
  
  $to = "MyEmailInbox@gmail.com";
  $from = "mail@example.com";
  
  $headers = "From: " . $from . "\r\n";
  
  $subject = "New subscription";
  $body = "New user subscription: " . $_POST['email'];
  
  
  if( filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) )
  { 
      if (mail($to, $subject, $body, $headers, "-f " . $from))
      {
          echo 'You will be notified on &lt;b&gt;  ' . $_POST['email'] . '&lt;/b&gt; :)';
      }
      else
      {
         echo 'There was a problem with your e-mail (' . $_POST['email'] . ')';   
      }
  }
  else
  {
     echo 'There was a problem with your e-mail (' . $_POST['email'] . ')';   
  }
  </code></pre>
  
  <p>As far as the index.html is concerned, I have a single form next to a Send button.  The form presumably takes the user information, filters nonsense out, and then the Send button calls the PHP script.  Please find the relevant index.html code below:</p>
  
  <pre><code>&lt;!-- SIGN UP SECTION ############################################### --&gt;
  
  &lt;section id="signup"&gt;
  
      &lt;div class="row"&gt;
  
          &lt;!-- Title --&gt; 
  
          &lt;div class="seven columns centered"&gt;
  
              &lt;h2&gt;Sign up to receive our newsletter!&lt;/h2&gt;
  
              &lt;!-- Begin the Form --&gt; 
  
              &lt;form action="form_sender.php" method="post"&gt;  
  
              &lt;!-- Input of E-Mail --&gt; 
  
              &lt;div class="eight columns"&gt;
  
                  &lt;input name="email" class="email" type="text" placeholder="YOUR E-MAIL PLEASE ?"&gt;
  
              &lt;/div&gt;
  
              &lt;!-- Send Button --&gt;
  
              &lt;div class="four columns"&gt;
  
                   &lt;button name="send" type="submit" class="submit"&gt;SEND&lt;/button&gt;
  
              &lt;/div&gt;
  
              &lt;!-- End of the Form --&gt; 
  
              &lt;/form&gt; 
  
  
          &lt;/div&gt;
  
          &lt;!-- Text Promise we do not spam --&gt;
  
          &lt;div class="twelve columns centered"&gt;
  
          &lt;p class="spam"&gt;We do not spam.&lt;/p&gt;
  
          &lt;/div&gt;
  
      &lt;/div&gt;
  
  &lt;/section&gt;
  </code></pre>