title: PHP Mail Function and Header Redirects Not Working Together
body: <p>The following code is used to send a email to users who's emails were provided by the user.</p>
  
  <pre><code>$from_whom_header = mysqli_real_escape_string($connect, 'noreply@test.com'); //setting a static from field
  
  $from_whom = mysqli_real_escape_string($connect, $_POST['your_email']); // this is used to pass the email of the person sending the email into the subject line and body of email
  
  $headers = 'From:'.$from_whom_header; //passing in static address stated above 
  
  $subject_email = $from_whom.'mentioned you in their latest post!';
  
  $body_email = '//email text...';
  
  
  if(@mail($to, $subject_email, $body_email, $headers))
  {
  
       echo ' emailing...';                                                                                   
  
  }
  
  else
  {
  
      $oh_noes_2 = '&lt;div class="error"&gt;'.'error sending mail'.'&lt;/div&gt;';
  
  } 
  
  
  header('Location: email_success.php');
  </code></pre>
  
  <p>For whatever reason, the header command is not working. I am using object buffering (ob_start() etc.) and I tried placing this script right under the ob start tags with still no result.</p>
  
  <p>My question then becomes is there some confusion in PHP between the $header used in the mail function and the header  command used to redirect? </p>
  
  <p>For some context, this script comes after some validation logic, and I put the echo 'emailing...' test in there for debugging and even when the header command was nested in there and the echo proved that the mail command was working, it still did not want to redirect.</p>