<?php 

if(isset($_POST['subject']) && isset($_POST['message']) && isset($_POST['matno']))
{  
	
	// Please specify your Mail Server - Example: mail.yourdomain.com.
ini_set("SMTP","mail.newsapp.ichurn.org");

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");

// Please specify the return address to use
ini_set('sendmail_from', 'info@newsapp.ichurn.org');

// multiple recipients
$to  = 'info@newsapp.ichurn.org'; // note the comma
//$to  = 'femisorinolu@gmail.com, ibitoye_ayodeji@yahoo.com'; // note the comma

// subject
$subject =$_POST['subject'];
$feedback_msg =$_POST['message'];
$recipients =$_POST['recipient'];
$user_id= $_POST['matno'];
$who=$_POST['who'];
$fullname=$_POST['fullname'];
$date=date("Y/m/d h:i:sa");

// message
$message = '
<html>
<head>
  <title>'.$subject.'</title>
</head>
<body>
  <p>Feedback message Made by '.$fullname.' On '.$date.'</p><br>
  <p>For '.$recipients.'</p><br>
  <p>User Type '.$who.'</p><br>
  <p>User ID '.$user_id.'</p><br>
  <p>Message :</p><br>
  <p>'.$feedback_msg.'</p><br>
</body>
</html>
';

// 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";

// Additional headers
$headers .= 'From: Push News App <info@newsapp.ichurn.org>';

// Mail it
if(mail($to, $subject, $message, $headers)) {
		 $response["error"] = FALSE;
           $response["error_msg"] = "Feedback message sent !";
            echo json_encode($response);

	}else{
		
		// user failed to store
            $response["error"] = TRUE;
            $response["error_msg"] = "Error occurred in sending feedback message!";
            echo json_encode($response);
		}
		 
}else{
	    // required post params is missing
    $response["error"] = TRUE;
    $response["error_msg"] = "Required parameters (user id, subject or message) is missing!";
    echo json_encode($response);

	
	}

?>
