File: /home/bibuzptr/elearning.bibu-edu.us/openuni/app/resetlnk-staff.php
<?php
session_start();
include_once('../includes/db_connect.php');
include_once "../includes/swiftmailer/swift_required.php";
$base_url="https://www.softmas.co.ke/openuni/";
if(isset($_POST['email'])){
$email = trim(mysqli_real_escape_string($con, $_POST['email']));
$emencoded = base64_encode($email);
$chkuser = mysqli_query($con,"SELECT * FROM lecturers WHERE email = '$email'");
if(mysqli_num_rows($chkuser) > 0){
$row = mysqli_fetch_assoc($chkuser);
$fname = $row["fullname"];
$link = $base_url."setpasswords/".$emencoded;
$notif = mysqli_fetch_assoc(mysqli_query($con,"SELECT * FROM notification_templates WHERE id='2'"));
$transport = Swift_SmtpTransport::newInstance('softmas.co.ke', 465, "ssl")
->setUsername('notifications@softmas.co.ke')
->setPassword('notif2019!');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance($notif["subject"])
->setFrom(array('notifications@softmas.co.ke' => 'Breakthrough Open University'))
->setTo(array($email => $fname))
->setContentType('text/html; charset=utf-8')
->setBody(str_replace(array("{name}","{link}"),array($fname,$link),$notif["body"]));
$numSent = $mailer->send($message);
echo "success";
}else{
echo "notfound";
}
}
?>