<?php

require_once "Mail.php"; // PEAR Mail package
require_once('Mail/mime.php'); // PEAR Mail_Mime packge
require 'vendor/autoload.php';

$name =  $user->first_name . " " . $user->last_name; // form field
$email = $user->email; // form field
$message = $_POST['message']; // form field

$status = false;

$from = "info@confirmid.com.ng"; //enter your email address
$to = $email; //enter the email address of the contact your sending to
$subject = "ConfirmID Platform Email Verification"; // subject of your email



$headers = array('From' => $from, 'To' => $to, 'Subject' => $subject);

$text = ''; // text versions of email.
$html = '<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>'; // html versions of email.

$crlf = "\n";

$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
//do not ever try to call these lines in reverse order
$body = $mime->get();
$headers = $mime->headers($headers);

$host = "localhost"; // your mail server i.e mail.mydomain.com
$username = "info@confirmid.com.ng"; //  your email address (same as webmail username)
$password = "@Magerpink12"; // your password (same as webmail password)

$smtp = Mail::factory('smtp', array(
	'host' => $host, 'auth' => true,
	'username' => $username, 'password' => $password
));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
// 	echo ($mail->getMessage());
	$status = false;
} else {
	$status = true;
// 	echo ("Message successfully sent!");
}