title: PHP mail() send files, don't understand boundary delimiter
body: <p>trying to send email via function mail()
  I receive an email without files. It was working sending only one file too.
  But this doesn't work sending multiple files.
  I don't understand how to use boundary? So my code doesn't work.</p>
  
  <pre><code>$passage_ligne = "\r\n";
  $boundary = "-----=".md5(rand());
  $boundary_alt = "-----=".md5(rand());
  
  $headers  = 'From:'.$nom.' &lt;'.$email.'&gt;' . "\r\n";
  $headers .= 'Return-Path: '.$nom.' &lt;'.$email.'&gt;'.$passage_ligne;     
  $headers .= "Message-ID:&lt;".time()." TheSystem@".$_SERVER['SERVER_NAME']."&gt;".$passage_ligne;
  $headers .= "X-Mailer: PHP v".phpversion().$passage_ligne;          
  $headers.= "MIME-Version: 1.0".$passage_ligne;
  $headers.= "Content-Type: multipart/mixed;".$passage_ligne." boundary=\"$boundary\"".$passage_ligne;
  
  $corps = $passage_ligne."--".$boundary.$passage_ligne;
  $corps.= "Content-Type: multipart/alternative;".$passage_ligne." boundary=\"$boundary_alt\"".$passage_ligne;
  $corps.= $passage_ligne."--".$boundary_alt.$passage_ligne;
  $corps.= "Content-Type: text/plain; charset=\"ISO-8859-1\"".$passage_ligne;
  $corps.= "Content-Transfer-Encoding: 8bit".$passage_ligne;
  $corps.= $passage_ligne.$message.$passage_ligne;
  $corps.= $passage_ligne."--".$boundary_alt.$passage_ligne;
  
  if(isset($_FILES["file"]) &amp;&amp;  $_FILES['file']['name'] != "")
  {
   $nom_fichier = $_FILES['file']['name'];
   $source = $_FILES['file']['tmp_name'];
   $type_fichier = $_FILES['file']['type'];
   $taille_fichier = $_FILES['file']['size'];
  foreach($_FILES as $photo){
  
      $tmp_name = $photo['tmp_name'];
      $type = $photo['type'];
      $name = $photo['name'];
      $size = $photo['size'];
  
      if (file_exists($tmp_name)){
  
          if(is_uploaded_file($tmp_name)){
  
              $file = fopen($tmp_name,'r');
              $data = fread($file,filesize($tmp_name));
              fclose($file);
              $data = chunk_split(base64_encode($data));
          }
  
      $corps .= $passage_ligne."--".$boundary."--".$passage_ligne;
      $corps .= "Content-Type: ".$type."; name=\"".$name."\"".$passage_ligne;
      $corps .= "Content-Transfer-Encoding: base64".$passage_ligne;
      $corps .= "Content-Disposition: attachment; filename='".$name."'".$passage_ligne;
      $corps .= $passage_ligne.$data.$passage_ligne.$passage_ligne;                   
      }
  }
  $corps.= $passage_ligne."--".$boundary."--".$passage_ligne;
  </code></pre>
  
  <p>Someone could explain this boundary to me please? How to use it?
  Thanks.</p>