Exemplo n.º 1
0
 public static function sendExceptionByMail(Exception $e, $from, $to)
 {
     // generate mail datas
     $subject = '[' . MAIN_URL . ':' . CONFIG_ENV . '] Exception Report: ' . wordlimit_bychar($e->getMessage(), 50);
     $body = $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine();
     // sned mail throw Zend_Mail
     $mail = new Zend_Mail();
     $mail->setSubject($subject)->setFrom($from)->setBodyText($body);
     $emails = explode(' ', $to);
     foreach ($emails as $email) {
         $mail->addTo($email);
     }
     $att = $mail->createAttachment(var_export($_GET, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'GET.txt';
     $att = $mail->createAttachment(var_export($_POST, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'POST.txt';
     // send session dump only if exists
     if (session_id() != null) {
         $att = $mail->createAttachment(var_export($_SESSION, true), Zend_Mime::TYPE_TEXT);
         $att->filename = 'SESSION.txt';
     }
     $att = $mail->createAttachment(var_export($_SERVER, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'SERVER.txt';
     $att = $mail->createAttachment($e->getTraceAsString(), Zend_Mime::TYPE_TEXT);
     $att->filename = 'backtraceExeption.txt';
     $mail->send();
 }
Exemplo n.º 2
0
 /**
  *
  */
 public static function sendExceptionByMail(Exception $e, $from, $to, $subjectPrefix = null)
 {
     // set default prefix as $_SERVER['HTTP_HOST'] then $_SERVER['SERVER_NAME'] then localhost
     if (is_null($subjectPrefix)) {
         $subjectPrefix = '[' . isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost') . ']';
     }
     // generate mail datas
     $subject = $subjectPrefix . ' - Exception Report: ' . wordlimit_bychar($e->getMessage(), 50);
     $body = $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine();
     // send mail throw Zend_Mail
     $mail = new Zend_Mail();
     $mail->setSubject($subject)->setFrom($from)->setBodyText($body);
     $emails = explode(',', $to);
     foreach ($emails as $email) {
         $mail->addTo($email);
     }
     $att = $mail->createAttachment(var_export($_GET, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'GET.txt';
     $att = $mail->createAttachment(var_export($_POST, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'POST.txt';
     // send session dump only if exists
     if (session_id() != null) {
         $att = $mail->createAttachment(var_export($_SESSION, true), Zend_Mime::TYPE_TEXT);
         $att->filename = 'SESSION.txt';
     }
     $att = $mail->createAttachment(var_export($_SERVER, true), Zend_Mime::TYPE_TEXT);
     $att->filename = 'SERVER.txt';
     $att = $mail->createAttachment($e->getTraceAsString(), Zend_Mime::TYPE_TEXT);
     $att->filename = 'backtraceExeption.txt';
     $mail->send();
 }