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();
}