<?php
class Email{
	public $subject;
	public $content;
	
	public function  __construct($subject, $content){
		require_once('connectdb.php');
		$con = new DbConnect;
		$this->con = $con->connect();
		
		$this->subject = $subject;
		$this->content = $content;
		
	}
	
	public function sendPasswordRecoveryEmail($email, $firstname, $user_id){
		require 'class.phpmailer.php';
		
		$mail = new PHPMailer;
		$mail->IsSMTP();								//Sets Mailer to send message using SMTP
		$mail->Host = 'mail.nethcarp.com';		//Sets the SMTP hosts of your Email hosting, this for Godaddy
		$mail->Port = '587';								//Sets the default SMTP server port
		$mail->SMTPAuth = true;							//Sets SMTP authentication. Utilizes the Username and Password variables
		$mail->Username = 'noreply@nethcarp.com';					//Sets SMTP username
		$mail->Password = 'PU[F;x^AGvC9';					//Sets SMTP password
		$mail->SMTPSecure = 'tls';							//Sets connection prefix. Options are "", "ssl" or "tls"
		$mail->From = 'noreply@nethcarp.com';			//Sets the From email address for the message
		$mail->FromName = 'Nethcarp';					//Sets the From name of the message
		$mail->AddAddress($email, $firstname);	//Adds a "To" address
		$mail->WordWrap = 50;							//Sets word wrapping on the body of the message to a given number of characters
		$mail->IsHTML(true);							//Sets message type to HTML
		$mail->Subject = 'Request for password reset on your Nethcarp Account'; //Sets the Subject of the message
		//An HTML or plain text message body
		$mail->Body = "
		  Hello $firstname
		  <p>You have requested for a password reset.</p>
		  <p>Click <a href='../reset-password?user_id=$user_id'>reset password</a> to reset your password</p>
		";

		$mail->AltBody = '';

		if($mail->Send()){
		    $output =  'sent';
		}else{
		    $output = 'Mailer Error: ' . $mail->ErrorInfo;
		    exit;
		}
		return $output;
	}
	
	public function sendPasswordResetConfirmation($email, $firstname){
		require 'class.phpmailer.php';
		
		$mail = new PHPMailer;
		$mail->IsSMTP();								//Sets Mailer to send message using SMTP
		$mail->Host = 'mail.nethcarp.com';		//Sets the SMTP hosts of your Email hosting, this for Godaddy
		$mail->Port = '587';								//Sets the default SMTP server port
		$mail->SMTPAuth = true;							//Sets SMTP authentication. Utilizes the Username and Password variables
		$mail->Username = 'noreply@nethcarp.com';					//Sets SMTP username
		$mail->Password = 'PU[F;x^AGvC9';					//Sets SMTP password
		$mail->SMTPSecure = 'tls';							//Sets connection prefix. Options are "", "ssl" or "tls"
		$mail->From = 'noreply@nethcarp.com';			//Sets the From email address for the message
		$mail->FromName = 'Nethcarp';					//Sets the From name of the message
		$mail->AddAddress($email, $firstname);	//Adds a "To" address
		$mail->WordWrap = 50;							//Sets word wrapping on the body of the message to a given number of characters
		$mail->IsHTML(true);							//Sets message type to HTML
		$mail->Subject = 'You have successfully resst you password'; //Sets the Subject of the message
		//An HTML or plain text message body
		$mail->Body = "
		  Hello $firstname
		  <p>Your have have successfully been able to reset your password.</p>
		  <p>Click <a href='../reset-password?user_id=$user_id'>reset password</a> to reset your password</p>
		";

		$mail->AltBody = '';

		if($mail->Send()){
		    $output =  'sent';
		}else{
		    $output = 'Mailer Error: ' . $mail->ErrorInfo;
		    exit;
		}
		return $output;
	}
}

?>