<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of KriaExceptionHandler
 *
 * @author a.ronchi
 */
class KriaExceptionHandler {

    private static $instance = null;

    public static function getInstance() {
        if (self::$instance == null) {
            $c = __CLASS__;
            self::$instance = new $c;
        }

        return self::$instance;
    }

    private function __construct() {
        
    }

    public function handleException($exceptionToHandle) {
//        echo "<img src'https://media.giphy.com/media/l44Qivn4ZgteMPLCE/giphy.gif'/>";
//        date_default_timezone_set('Etc/UTC');
//        $mail = new PHPMailer;
//        $mail->isSMTP();
//        $mail->SMTPOptions = array(
//            'ssl' => array(
//                'verify_peer' => false,
//                'verify_peer_name' => false,
//                'allow_self_signed' => true
//        ));
//        $mail->SMTPDebug = 1;
////$mail->Debugoutput = 'html';
//        $mail->Host = 'smtp.gmail.com';
//        $mail->Port = 587;
//        $mail->SMTPSecure = 'tls';
//        $mail->SMTPAuth = true;
//        $mail->Username = "noreply@kria.biz";
//        $mail->Password = "kriaadmin";
//        $mail->setFrom('noreply@kria.biz', 'Kria s.r.l.');
//
//        $mail->addAddress('a.ronchi@kria.biz', '');
//        $mail->Subject = "test test 123";
//        $mail->msgHTML("test<b>123!</b>");
//
//
//        if (!$mail->send()) {
//            $errors = "Errori Mailer: " . $mail->ErrorInfo;
//        } else {
//            $errors = "<h5>Sent!</h5>";
//        }
        $message = new YiiMailMessage;
        //this points to the file test.php inside the view path
        $message->subject = 'My TestSubject';
        $message->setBody("test", 'text/html');
        $message->addTo('a.ronchi@kria.biz');
        $message->from = 'noreply@kria.biz';
        Yii::app()->mail->send($message);
    }

}
