<head>
<meta http-equiv="refresh" content="4; URL='http://portal.niqs.org.ng'" />
</head>
<?php
//PHP Mail Salisu
                    // Import PHPMailer classes into the global namespace
                    // These must be at the top of your script, not inside a function
                    use PHPMailer\PHPMailer\PHPMailer;
                    use PHPMailer\PHPMailer\SMTP;
                    use PHPMailer\PHPMailer\Exception;

                    // Load Composer's autoloader
                    require './vendor/autoload.php';

                    // Instantiation and passing `true` enables exceptions
                    $mail = new PHPMailer(true);

                    try {
                        //Server settings
                        $mail->isSMTP();                                            // Send using SMTP
                        $mail->Host       = 'c16252.sgvps.net';                    // Set the SMTP server to send through
                        $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
                        $mail->Username   = 'info@niqs.org.ng';                     // SMTP username
                        $mail->Password   = '1969niqsheadofficeabuja';                               // SMTP password
                        $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
                        $mail->Port       = 587;                                    // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

                        //Recipients
                        $mail->setFrom('info@niqs.org.ng', 'NIQS');
                        //$mail->addAddress('info@niqs.org.ng', 'Joe User');     // Add a recipient
                        //$email = "salisu@niqs.org.ng";
                        if(isset($_GET['email'])){$email = urldecode($_GET['email']); }
                        if(isset($_GET['i'])){$password = urldecode($_GET['i']); }
                        
                        $mail->addAddress($email);               // Name is optional
                        $mail->addReplyTo('membership@niqs.org.ng', 'NIQS Membership');

                        // Content
                        $mail->isHTML(true);                                  // Set email format to HTML
                        $mail->Subject = 'Password Reset';

                        $mail->Body    =  'Hello, <p>You requested a password reset recently on the portal. Your new password is '.$password.'.<br><br> Kind regards. <br>NIQS';
                        $mail->AltBody = 'Hello, You requested a password reset recently on the portal. Your new password is '.$password.'. Kind regards.';

                        $mail->send();
                        echo '<script>window.alert("Your password reset is successful and a new password has been sent to your email");</script>';
                        echo '<script>window.location.replace("http://portal.niqs.org.ng"); </script>';              
                    } catch (Exception $e) {
                        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
                    }
                    //PHP Mail Salisu--

?>