title: php email approval
body: <p>I have a small web app where people can send a message via email to a group. Because of spam I will have to make an approval procedure.</p>
  
  <p>The messages are being sent via PHP. How am I doing so I have to accept the message before its send to an email that forward it to the group?</p>
  
  <p>My PHP:</p>
  
  <pre><code>&lt;?php 
  $errors = '';
  $myemail = 'whatever@gmail.com';//&lt;-----Put Your email address here.
  if(empty($_POST['name'])  || 
     empty($_POST['email']) || 
     empty($_POST['message']))
  {
      $errors .= "\n FEJL: Alle felter skal udfyldes";
  }
  
  $name = $_POST['name']; 
  $email_address = $_POST['email']; 
  $message = $_POST['message']; 
  $email_subject = "Form request";
  $times = $_POST["timeslots"];
  
  if (!preg_match(
  "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
  $email_address))
  {
      $errors .= "\n FEJL: Ugyldig email adresse";
  }
  $strTimes = implode($times);
  if( empty($errors))
  {
  $to = $myemail; 
  $email_subject = "$message \n ";
  $email_body = "\n Code: $strTimes \n Navn: $name \n Email: $email_address \n"; 
  
  $headers = "From: $email_address\n"; 
  $headers .= "Reply-To: $email_address";
  
  mail($to,$email_subject,$email_body,$headers);
  //redirect to the 'thank you' page
  header('Location: thx.html');
  } 
  ?&gt;
  </code></pre>