<?php

require 'PHPMailer-master/src/Exception.php';
require 'PHPMailer-master/src/PHPMailer.php';
require 'PHPMailer-master/src/SMTP.php';



use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;


$mail = new PHPMailer(true);





$email_content = '<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Email Verification</title>
	<style>
		body {
			font-family: Arial, sans-serif;
			font-size: 14px;
			line-height: 1.5;
			color: #333333;
			background-color: #f5f5f5;
			padding: 20px;
		}
		h1 {
			font-size: 24px;
			margin-bottom: 20px;
		}
		p {
			margin-bottom: 20px;
		}
		a {
			display: inline-block;
			padding: 10px 20px;
			background-color: #007bff;
			color: #fff;
			text-decoration: none;
			border-radius: 5px;
		}
		a:hover {
			background-color: #0069d9;
		}
	</style>
</head>
<body>
	<h1 style="color:black">Email Verification</h1>
	<p style="color:black">Hi there,</p>
	<p style="color:black">Thanks for signing up for our service! To complete your registration, please click the link below to verify your email address:</p>
	<p><a style="color:white" href="'.ROOT_URL.'/verify.php?verification=' . base64_encode($user->id).'">Verify Email Address</a></p>
	<p style="color:black">If you did not sign up for our service, please ignore this email.</p>
	<p style="color:black">Thanks,</p>
	<p style="color:black">The VerifyAll Team</p>
</body>
</html>
';

// <a href="ROOT_URL/reset_pass.php?ii=base64_encode($user->id)&mm=base64_encode($user->email)">ROOT_URL/pass_reset.php?ii=base64_encode($user->id)&mm=base64_encode($user->email)</a>





try {
    //Server settings
    $mail->isSMTP();
    //Enable SMTP debugging
    SMTP::DEBUG_OFF; //(for production use)
    // SMTP::DEBUG_CLIENT = client messages
    // SMTP::DEBUG_SERVER = client and server messages                                      //Send using SMTP
    $mail->Host       = 'localhost';                     //Set the SMTP server to send through
    // $mail->SMTPDebug = SMTP::DEBUG_SERVER; 
    $mail->SMTPAuth = true; 
    $mail->Host       = 'smtp.gmail.com';   
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
    // $mail->Username   = 'info@verifyall.com';                     //SMTP username
    $mail->Username   = EMAIL_USERNAME;                     //SMTP username
    $mail->Password   = EMAIL_PASSWORD;                               //SMTP password
    // $mail->Password   = '@Magerpink12';                               //SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;            //Enable implicit TLS encryption
    $mail->Port       = 465;                                    //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

    //Recipients
    $mail->setFrom('info@verifyall.com.ng', 'VerifyAll Platform');
    $mail->addAddress($user->email,  $user->first_name . " " . $user->last_name);

    //Attachments
    // $mail->addAttachment('../print/tickets/' . $reference . '.pdf', $reference . '.pdf');    //Optional name

    //Content
    $mail->isHTML(true);                                  //Set email format to HTML
    $mail->Subject = 'VerifyAll';
    $mail->Body    = $email_content;
    // $mail->Body    = '<p>Click the link below to verify your account</p>
    // <a href="' . ROOT_URL . '/verify.php?verification=' . base64_encode($user->id) . '">' . ROOT_URL . '/verify.php?verification=' . base64_encode($user->id) . '</a>';
    // $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if($mail->send()){
    // echo "sent..................";
    $status =true;
}else{
    // echo "not sent..................";
    $status =false;
    
}
   
} catch (Exception $e) {
    $erro = "Verification mail not sent";
}
