title: Change PHP Form to Permanent Sender
body: <p>When someone fills out a form on our website it uses the person filling out the forms email address.  Our hosting company is blocking the emails because the person filling out the form is set as the 'From'.  From our hosting company:</p>
  
  <p>"You'll need to ensure that the form is permanently set with a DreamHost
  hosted email address so that this form works properly and isn't rejected.
  It may be set so that the person filling out the form is being set as the
  'From', which will result in the rejection above. </p>
  
  <p>Just edit the form so that the 'From' is permanently set to a DH user so
  that the form is no longer rejected due to policy reasons."</p>
  
  <p>What changes do I need to make to the below code to make this acceptable to Dreamhost?  Any help would be greatly appreciated.</p>
  
  <pre><code>    &lt;?php
  if(isset($_POST['email'])) {
  
  // EDIT THE 2 LINES BELOW AS REQUIRED
  $email_to = "eileenw@ourdomain.com";
  $email_subject = "Quiz";
  $your_email = "info@ourdomain.com";
  
  
  function died($error) {
      // your error code can go here
      echo "&lt;p&gt;We are very sorry, but there were error(s) found with the form you submitted.&lt;/p&gt; ";
      echo "These errors appear below.&lt;br /&gt;&lt;br /&gt;";
      echo $error."&lt;br /&gt;&lt;br /&gt;";
      echo "&lt;p&gt;Please go back and fix these errors.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;";
      die();
  }
  
  // validation expected data exists
  if(!isset($_POST['first_name']) ||
      !isset($_POST['last_name']) ||
      !isset($_POST['email']) ||
      !isset($_POST['telephone']) ||
      !isset($_POST['comments'])) {
      died('We are sorry, but there appears to be a problem with the form you submitted.');      
  }
  
  $first_name = $_POST['first_name']; // required
  $last_name = $_POST['last_name']; // required
  $email_from = $_POST['email']; // required
  $telephone = $_POST['telephone']; // not required
  $address = $_POST['address']; // not required
  $city = $_POST['city']; // not required
  $state = $_POST['state']; // not required
  $vehicleyear = $_POST['vehicleyear']; // not required
  $vehiclemake = $_POST['vehiclemake']; // not required
  $vehiclemodel = $_POST['vehiclemodel']; // not required
  $purchase_or_lease = $_POST['purchase_or_lease']; // not required
  $deliverydate = $_POST['deliverydate']; // not required
  $mileage_at_delivery = $_POST['mileage_at_delivery']; // not required
  $current_mileage = $_POST['current_mileage']; // not required
  $seller = $_POST['seller']; // not required
  $citystate = $_POST['citystate']; // not required
  $Bank_Finance = $_POST['Bank_Finance']; // not required
  $dealer_arranged = $_POST['dealer_arranged']; // not required
  $employee_discount = $_POST['employee_discount']; // not required
  $warranty = $_POST['warranty']; // not required
  $length_contract = $_POST['length_contract']; // not required
  $comments = $_POST['comments']; // not required
  
  $error_message = "";
  $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!preg_match($email_exp,$email_from)) {
  $error_message .= 'The Email Address you entered does not appear to be valid.&lt;br /&gt;';
  }
  $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
  $error_message .= 'The First Name you entered does not appear to be valid.&lt;br /&gt;';
  }
  if(!preg_match($string_exp,$last_name)) {
  $error_message .= 'The Last Name you entered does not appear to be valid.&lt;br /&gt;';
  }
  
  if(strlen($error_message) &gt; 0) {
  died($error_message);
  }
  $email_message = "Form details below.\n\n";
  
  function clean_string($string) {
    $bad = array("content-type","bcc:","to:","cc:","href");
    return str_replace($bad,"",$string);
  }
  
  $email_message .= "First Name: ".clean_string($first_name)."\n";
  $email_message .= "Last Name: ".clean_string($last_name)."\n";
  $email_message .= "Email: ".clean_string($email_from)."\n";
  $email_message .= "Telephone: ".clean_string($telephone)."\n";
  $email_message .= "Address: ".clean_string($address)."\n";
  $email_message .= "City: ".clean_string($city)."\n"; 
  $email_message .= "State: ".clean_string($state)."\n";
  $email_message .= "Vehicle Year: ".clean_string($vehicleyear)."\n";
  $email_message .= "Make: ".clean_string($vehiclemake)."\n";
  $email_message .= "Model: ".clean_string($vehiclemodel)."\n";
  $email_message .= "Purchase or Lease: ".clean_string($purchase_or_lease)."\n";
  $email_message .= "Delivery date: ".clean_string($deliverydate)."\n";
  $email_message .= "Mileage at Delivery: ".clean_string($mileage_at_delivery)."\n";
  $email_message .= "Current Mileage: ".clean_string($current_mileage)."\n";
  $email_message .= "Selling Dealer: ".clean_string($seller)."\n";
  $email_message .= "Seller City and State: ".clean_string($citystate)."\n";
  $email_message .= "Bank or Finance Company: ".clean_string($Bank_Finance)."\n";
  $email_message .= "Dealer Arranged: ".clean_string($dealer_arranged)."\n";
  $email_message .= "Employee Discount? ".clean_string($employee_discount)."\n";
  $email_message .= "Warranty: ".clean_string($warranty)."\n";
  $email_message .= "Contract Terms: ".clean_string($length_contract)."\n";
  $email_message .= "Comments: ".clean_string($comments)."\n";
  
  
  
  // create email headers
  $headers = 'From: ' . $your_email . "\r\n";
  'Reply-To: '.$email_from."\r\n" .
  'X-Mailer: PHP/' . phpversion();
  @mail($email_to, $email_subject, $email_message, $headers); 
  ?&gt;
  </code></pre>