title: Sending HTML newsletters with plain-text fallback
body: <p>I am currently using a script which uses file_get_contents to get the contents of a php file, and then sends it inside an email to a list of customers. I would like to alter the script to allow for plain-text fallback to reduce the risk of being marked as spam.</p>
  
  <p>This is the script I have at the moment:</p>
  
  <pre><code>    function sendit($to,$subject,$body)
  {
  $headers    =   "To: &lt;{$to}&gt;\n".
                      "From: Test Newsletter Admin &lt;newsletter@test.co.uk&gt;\n".
                      "Reply-To: Test Newsletter Admin &lt;newsletter@test.co.uk&gt;\n".
                      "MIME-Version: 1.0\n".
                      "Content-Type: text/html; charset=ISO-8859-1\n";
  
      $mail_sent = @mail($to, $subject, $body, $headers);
      return $mail_sent;
  }
  $content = file_get_contents('attach/newsletter.php');
  //require_once('../../func.php');
  set_time_limit(0);
  date_default_timezone_set('Europe/London');
  
  $log = fopen('send'.date('dmY',time()).'.log','wb');
  
  //$array = file('NonCustClean.txt');
  $array = file('devaddresses.txt');
  // Delay In Seconds between emails (must be INT)
  $delay = 10;
  $count = count($array);
  
  $end = time()+ ($delay*$count);
  
  echo "Start Time: ".date('d/m/Y H:i:s',time()).'&lt;br /&gt;';
  echo "Estimated End Time: ".date('d/m/Y H:i:s',$end).'&lt;br /&gt;';
  echo "(".dateDiff(time(),$end).")&lt;br /&gt;"; 
  
  foreach ($array as $email)
   {
  
  $status = (sendit(trim($email), 'Test Newsletter',$content))?'Sent':'failed';
   fwrite($log,date('[d/m/Y H:i:s]',time()).' Email '.$status.' to '.trim($email)."\n");
   echo date('[d/m/Y H:i:s]',time()).' Email '.$status.' to '.trim($email)."&lt;/br&gt;";
   flush(); 
    sleep(10);
   }
  </code></pre>
  
  <p>Newsletter.php just contains basic HTML/CSS code.</p>
  
  <p>Could someone please advise how I can alter this script to accompany a plain-text fallback?</p>
  
  <p>Thanks for any help.</p>