<?php
require("PHPMailer/class.phpmailer.php");
//$to='dinesh@apiit.lk';
$to=$cb_number.'@students.apiit.lk';
$tow='dinesh@apiit.lk';
$message='<table style="font-family:Verdana, Geneva, sans-serif; font-size: 12px; background:#999999; width:700px; border:none;" cellpadding="4" cellspacing="1">
    <tr>
      <td align="left" style="font-weight:bold; font-variant:small-caps; background:#eeeeee;" colspan="2"><b>Cancellation of Student Incentive Form</b></td>
    </tr>
    <tr>
      <td align="left" style="background:#ffffff;">Form Number</td>
      <td align="left" style="background:#ffffff;">'.$request_id.'</td>
    </tr>
    <tr>
      <td align="left" style="background:#ffffff;" width="150px">Request Date</td>
      <td align="left" style="background:#ffffff;">'.$request_date.'</td>
    </tr>
    <tr>
      <td align="left" style="background:#ffffff;">CB Number</td>
      <td align="left" style="background:#ffffff;">'.$cb_number.'</td>
   </tr>
    <tr>
      <td align="left" style="background:#ffffff;">Student Name</td>
      <td align="left" style="background:#ffffff;">'.$st_name.'</td>
   </tr>
    <tr>
      <td align="left" style="font-weight:bold; font-variant:small-caps; background:#eeeeee;"><b>Sorry your student 
incentive form has been cancelled due to following reason(s)</b></td>
	<td align="left" style="background:#ffffff;">'.$comment.'</td>
    </tr>
     <tr align="center">
      <td align="left" style="font-weight:bold; font-variant:small-caps; background:#eeeeee;" colspan="2"><b>Rejected by:- '.$getfname.' | Date:- '.$curdate.'</b></td>
    </tr>
  </table>';
$subject='hi';
    $mail = new PHPMailer(); // create a new object
    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = "172.16.3.2";
    $mail->Port = 25; // or 587
    $mail->IsHTML(true);
    $mail->Username = "email";
    $mail->Password = "Cis852L>5";
    $mail->SetFrom("email@apiit.lk");
    $mail->FromName="APPAdmin";
    $mail->AddAddress($to);
    $mail->AddCC($tow);
    $logfile = dirname(dirname(__FILE__)) . '/mail.log';
    try {
        $mail->Body = $message;
        $mail->Subject = $subject;


        file_put_contents($logfile, "Content: \n", FILE_APPEND);
        file_put_contents($logfile, $message . "\n\n", FILE_APPEND);

        if(!$mail->Send()) {
            echo "Mailer Error: " . $mail->ErrorInfo;
        } else {
            echo "Email has been sent";
        }
    } catch (Exception $e) {
        #print_r($e->getMessage());
        file_put_contents($logfile, "Error: \n", FILE_APPEND);
        file_put_contents($logfile, $e->getMessage() . "\n", FILE_APPEND);
        file_put_contents($logfile, $e->getTraceAsString() . "\n\n", FILE_APPEND);
    }
	?>
