<?php 
require_once('Mailer.php');
class MyExceptions extends Communicator{
	  //email of the receipent (Administrator)
	  private $mailTo = "shahhussain305@gmail.com";
	  //email sender, it should be a valid email address of sender
	  private $mailFrom = "admin@xyz.com";
	  //optional parameter sender name
	  private $senderName = "Auto Exceptions Sender";
	  //email subject 
	  private $mail_subject = "Exception Details";
	  //message containing exceptions detail
	  private $msg = "";
	  //if need to send any attached file as an attachement use path in the following vairable
	  private $attachmentPath = "";
	 //catchError() function takes PDOException object variable as a parameter
	  //Send Error detrails to Admin valid email address
	  public function catchError($errorObj){
		  $this->msg = '<strong>Exception occured:</strong><br />'.$errorObj->getMessage().'
		                <br /><br />Message Sent from <br />'.$_SERVER['HTTP_HOST'].'<br />
						<br />Message For Web Master';
		  if($this->sendEmail($this->mailTo,$this->mailFrom,$this->senderName,$this->mail_subject,$this->msg,$this->attachmentPath)){
		  	//mail sent to receipent with error message generated by PDOException object
			echo($this->msg);
		 	 }
		  }
		  
	}
?>