<?php

	$date = "5 Septembre 2017";
	$horaire = "22H20";
	$prenom = "Patrice";
	$email = "patrice.delpy@onsemi.com";
	
	//$msg = "First line of text\nSecond line of text";
	//$msg = wordwrap($msg,70);
	//mail("patrice.delpy@onsemi.com","My subject",$msg);

	$jour  = date("d-m-Y");
	$heure = date("H:i:s");

	$sujet = 'Massage annulation: Accusé de réception ';
	$sujet = utf8_decode($sujet);
	$sujet = mb_encode_mimeheader($sujet,"UTF-8");

	$message = "<br /><br />
	$jour à $heure, <br /><br />
	<strong>Bonjour $prenom,
	<br><br>
	Tu viens d'annuler un massage pour la date suivante:
	<br> 
	Le $date à $horaire  
	</strong>";
	
	$message .= "<br> <br>	A Bientôt :)";
	
	//mail("patrice.delpy@onsemi.com", $sujet ,$message);
	
	///
	
	date_default_timezone_set('Europe/Paris');
 
	$from_name = "Robot Massage - no reply";
	$from_address = "robmyname@mydomain.com";
	$subject = "Réservation massage"; 
	$location = "Salle de repos";
 
	//Create Mime Boundry
	$mime_boundary = "----Réservation----".MD5(time());
 
	//Create Email Headers
	$headers = "From: ".$from_name." <".$from_address.">\n";
	$headers .= "Reply-To: ".$from_name." <".$from_address.">\n";
 
	$headers .= "MIME-Version: 1.0\n";
	$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
	$headers .= "Content-class: urn:content-classes:calendarmessage\n";
	
	
	//Create Email Body (HTML)
	$message .= "--$mime_boundary\n";
	$message .= "Content-Type: text/html; charset=UTF-8\n";
	$message .= "Content-Transfer-Encoding: 8bit\n\n";
 
	$message .= "<html>\n";
	$message .= "<body>\n";
	$message .= '<p>'.$prenom.',</p>';
    $message .= "<p> Tu viens d'annuler un massage pour la date suivante: </p>";
    $message .= "<p> Le $date à $horaire .</p>";
	$message .= "<p><br></p>";
    $message .= '<p>'."A bientôt :)".'</p>';
	  
	$message .= "</body>\n";
	$message .= "</html>\n";
	$message .= "--$mime_boundary\n";
	
	$message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST\n';
	$message .= "Content-Transfer-Encoding: 8bit\n\n";
	          
	
	$mail_sent = @mail( $email, $subject, $message, $headers );
	
	echo "Email send";
	
	//https://css-tricks.com/sending-nice-html-email-with-php/

?> 