<?php
require("PHPMailer/class.phpmailer.php");
$to= $admin_mail;
$to1="dinesh@students.apiit.lk";
/*$to=$cb_number.'@students.apiit.lk'; disable till correct email*/
$message='<table style="font-family:Verdana, Geneva, sans-serif; font-size: 12px; background:#999999; width:60%; border:none;" cellpadding="4" cellspacing="1">
	<tr>
	<td colspan="2">'.$alert.'</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;">'.$curdate.'</td>
    </tr>
    <tr>
      <td align="left" style="background:#ffffff;">Requester CB Number</td>
      <td align="left" style="background:#ffffff;">'.$cb_number.'</td>
   </tr>
<tr>
      <td align="left" style="background:#ffffff;"> Requester Name</td>
      <td align="left" style="background:#ffffff;">'.$st_name.'</td>
   </tr>
   <tr>
      <td align="center" style="background:#06F; height:20px;" colspan="2"><a href="http://apps.apiit.lk/ctrl/">Click here</a></td>
   </tr>
  </table>';
$subject=$email_subject;
    $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($to1);
  //  $mail->AddAddress($to2);
    $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 "<center><h1>Email has been sent</h1></center>";
        }
    } 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);
    }
	?>
