Skip to content

Instantly share code, notes, and snippets.

@demonio
Last active October 4, 2016 14:05
Show Gist options
  • Save demonio/540ea9f3eab31d113ad864ab6595af0a to your computer and use it in GitHub Desktop.
Save demonio/540ea9f3eab31d113ad864ab6595af0a to your computer and use it in GitHub Desktop.
Excepción al correo
<?php
[...]
/**
* Maneja las excepciones no capturadas
*
* @param Exception $e
* */
public static function handleException($e)
{
if ( ! PRODUCTION )
{
#die('<pre>'.print_r($e,1));
$body["MESSAGE"] = $e->getMessage() ? $e->getMessage() : $e->view;
$body["SERVER"] = $_SERVER["SERVER_NAME"] .':'.$_SERVER["SERVER_PORT"];
if ( ! empty($_SERVER["HTTP_REFERER"]) ) $body["HTTP_REFERER"] = $_SERVER["HTTP_REFERER"];
$body["REQUEST_URI"] = $_SERVER["REQUEST_URI"];
$body["REMOTE_ADDR"] = $_SERVER["REMOTE_ADDR"];
$body["REMOTE_USER"] = $_SERVER["REMOTE_USER"];
$body["HTTP_USER_AGENT"] = $_SERVER["HTTP_USER_AGENT"];
$to = 'AQUI_TU_EMAIL';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
mail($to, 'ERROR: '.$body["MESSAGE"], '<pre>'.print_r($body,1), $headers);
}
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment