<?php
function mailfichier($from, $to, $subject, $body, $nomfichier) {
  // generation du separateur, une chaine aleatoire fait l'affaire
  $bound = '------------'.md5(uniqid('toto'));

  $entete = 'From: '.$from."\n"
    .'MIME-Version: 1.0'."\n"
    .'Content-Type: multipart/mixed;'."\n"
    .' boundary="'.$bound.'"';
	
	$toto = '
		<html><head>
    <meta content="text/html; charset=windows-1252" http-equiv="content-type">
    <title> Confirmation Reservation </title>
  </head>
  <body>
    <table style="width: 664px; background-color: lightskyblue;" border="1">
      <tbody>
	  
        <tr>
          <td style="background-color: lightskyblue; height: 169.55px;" colspan="3" rowspan="1">
		  <span style="color: #3333ff;">
		  <img src="http://www.analog-design.net/WORKAREA/WEBSITE/Location site/Location_17_11_2014//img/plage.jpg" alt="" width="99%" height="200"  title="Bonne anse" align="middle">
		  
		  </span>
		  </td>
        <td>
            <div style="text-align: left;">
              <h2 style="background-color: lightskyblue;">
			  <span style="color: #2828ca;">
			  <span style="font-style: italic;">
			  <span style="font-weight: bold;">Bonne Anse Plage</span>
			  </span>
			  </span></h2>
            </div>
            <div align="center">Location MobilHome <span style="text-decoration: underline;"><br>
            </span></div></td>
        </tr>
        <tr align="center">
          <td colspan="4" rowspan="1" valign="middle" style="height: 66.8333px;">
            <h2>Confirmation de votre r&eacute;servation </h2>
          </td>
        </tr>
        <tr>
          <td style="width: 148.35px;"><span style="font-weight: bold;"> Nom</span></td>
          <td style="height: 20px;" colspan="3" rowspan="1">';
		  $message.= $nom;
		  $message.= '
		  <br>
          </td>
        </tr>
        
        <tr>
          <td><strong>Pr&eacute;nom</strong><br>
          </td>
          <td colspan="3" rowspan="1">';
		  $message.= $prenom;
		  $message.= '
		  <br>
          </td>
        </tr>
             
         <tr>
          <td><strong>T&eacute;l&eacute;phone</strong><br>
          </td>
          <td colspan="3" rowspan="1">';
		  $message.= $tel;
		  $message.= '
		  <br>
          </td>
        </tr>    
             
         <tr>
          <td><strong>Email</strong><br>
          </td>
          <td colspan="3" rowspan="1">';
		  $message.= $email;
		  $message.= '
		  <br>
          </td>
        </tr>    
        
        <tr>
          <td><strong>Jour d\'arrivée</strong><br>
          </td>
          <td>';
		  $message.= $date1;
		  $message.= '
		  <br>
          </td>
          <td><strong>Heure d\'arrivée</strong><br>
          </td>
          <td>';
		  $message.= "Aprés4H";
		  $message.= '
		  <br>
          </td>
        </tr>
		
        <tr style="height: 23px;">
          <td><strong>Jour de départ</strong><br>
          </td>
          <td>';
		  $message.= $date2;
		  $message.= '
		  <br>
          </td>
          <td><strong>Heure du départ</strong><br>
          </td>
          <td>';
		  $message.= "Avant 12H";
		  $message.= '
		  <br>
          </td>
        </tr>
		
		 <td><strong>Nombre de personne</strong><br>
          </td>
          <td colspan="3" rowspan="1">';
		  $message.= $nb_personne;
		  $message.= '
		  <br>
          </td>
		
        <tr>
          <td><strong></strong></td>
          <td><br>
          </td>
          <td><strong></strong></td>
          <td><br>
          </td>
        </tr>
        <tr>
          <td><strong></strong></td>
          <td colspan="3" rowspan="1"><br>
          </td>
        </tr>
        <tr>
          <td><strong></strong></td>
          <td colspan="3" rowspan="1"><br>
          </td>
        </tr>
        <tr>
          <td><strong></strong></td>
          <td colspan="3" rowspan="1"><br>
          </td>
        </tr>
        <tr>
          <td><strong></strong></td>
          <td colspan="3" rowspan="1"><br>
          </td>
        </tr>
        <tr>
          <td colspan="4" rowspan="1">
            <div style="text-align: center;"><strong><span style="text-decoration: underline;">*Procédure</span>*</strong></div>
            <ul>
              <li>Vous trouverez le contrat de location en piéce jointe.</li>
              
              
            </ul>
            Cordialement,<br>
            <br>
            <br>
            Pour me contacter: <br>
            patrice.delpy@free.fr</td>
        </tr>
      </tbody>
    </table>
    <p><br>
    </p>
  

</body></html>'	;
	

  $body = 'This is a multi-part message in MIME format.'."\n"
    .'--'.$bound."\n"
    .'Content-Type: text/plain; charset=ISO-8859-1'."\n"
    .'Content-Transfer-Encoding: 7bit'."\n\n"
    .$toto
    ."\n\n"
    .'--'.$bound."\n"
    .'Content-Type: text/plain;'."\n".' name="'.basename($nomfichier).'"'."\n"
    .'Content-Transfer-Encoding: base64'."\n"
    .'Content-Disposition: attachment;'."\n".' filename="'.basename($nomfichier).'"'."\n\n"
    .chunk_split(base64_encode(file_get_contents($nomfichier)))
    .'--'.$bound.'--'."\n";

  return @mail($to, $subject, $body, $entete);
}


$from = "patrice.delpy@neuf.fr";
$to = "patrice.delpy@neuf.fr";
$subject = "sujet";
$body = "corps du mail";
$nomfichier = "word.doc";


echo mailfichier($from, $to, $subject, $body, $nomfichier);


?>