<?php
    //header("Access-Control-Allow-Origin","*");
	header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization');
	$token = $_POST['token'];		
	$fullname = $_POST['fullname'];	
	$email = $_POST['email'];	
	$phone = $_POST['phone'];
	$message = $_POST['message'];	
	
    if($token == '2XGso5jap24RSLlLP6upw5W05sTSmoUqtMidFbs6'){
		//echo $month." ".$dateq." ".$phone." ".$email." ".$fullname." ".$country.' '.$number.' '.$amount;
			$to = 'gadstony@zoho.com';
			$subject = $fullname.' send an email';
			$from = $email;
			// To send HTML mail, the Content-type header must be set
			$headers  = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
			// Create email headers
			$headers .= 'From: '.$from."\r\n".
				'Reply-To: '.$from."\r\n" .
				'Return-Path: '.$to."\r\n" .
				'X-Mailer: PHP/' . phpversion();
			// Compose a simple HTML email message
			$message = '<html><body style="background: #b2b0aa;margin:0 auto;width:100%">';
			$message .= '<div style="background:#ffffff;margin:0 auto;max-width:700px">';
			$message .= '<div style="background:#ffffff;padding:15px 20px;border-bottom:6px solid #893d23;">';
           $message .= '</div>';
			$message .= '<div style="box-shadow:0px 0px 10px rgba(0,0,0,0.2)">';

            $message .= '<div style="font-size:2em;margin:0;background:#524d40;color:#ffffff;text-align:center;padding:1.5em 0">Message from Website</div>';

			$message .= '<div style="background:#ffffff;padding:30px 20px;border-bottom:0px solid #893d23">';
            $message .= '<div style="font-size:1.6em;margin-bottom:10px">Details:</div>';

            $message .= '<div style="background:#cdcdcd;height:1px;margin:10px 0;clear:both"></div>';
            $message .= '<div style="margin:1em 0;font-size:1em;color:#524d40">Full Name: <span style="color:#202020">'.$fullname.'</span></div>';
            $message .= '<div style="margin:1em 0;font-size:1em;color:#524d40">Email: <span style="color:#202020">'.$email.'</span></div>';
            $message .= '<div style="margin:1em 0;font-size:1em;color:#524d40">Phone: <span style="color:#202020">'.$phone.'</span></div>';

            $message .= '<div style="background:#cdcdcd;height:1px;margin:10px 0;clear:both"></div>';
            $message .= '<div style="margin:1em 0;font-size:1em;color:#524d40">Message: <span style="color:#202020"></br></br>'.$message.'</span></div>';
			$message .= '</div>';
			$message .= '</div>';
			$message .= '<div style="background:#b2b0aa;color:#524d40;padding:30px 20px;">';
			$message .= '<p style="font-size:1em;text-align:center">Copyright &copy; 2019 All Right Reserved<br> Duhozanye Association<br>KN 4 Avenue, Kiyovu<br>Kigali, Rwanda</p>';
			$message .= '</div>';
			$message .= '</div>';
			$message .= '</div>';
			$message .= '</body></html>';
			// Sending email
			if(mail($to, $subject, $message, $headers)){
				echo 'Your mail has been sent successfully.';
			} else{
				echo 'Unable to send email. Please try again.';
			}
	}else{
		echo false;
	}

