dpm_mail
Categories
Component ID
1376308
Component name
dpm_mail
Component type
module
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
Sometimes you cannot display any debug messages on your site, so here is dpm_mail.
You can sen a message with:dpm_mail($var)
By default the message will be send to the site mail. When you don't want that you can set the second parameter with you e-mail address:dpm_mail($var, 'joe@aol.com');
I would recommend that you just copy the function into your code instead of install the module:
function dpm_mail($var, $to = NULL) {
$backtrace = debug_backtrace();
$to = !empty($to) ? $to : variable_get('site_mail', '');
$subject = $backtrace[0]['file'] . ' - line ' . $backtrace[0]['line'];
$mail = "From: " . variable_get('site_name', 'Drupal') . " <" . variable_get('site_mail', '') . ">
";
$mail .= "Content-Type: text/html
Content-Transfer-Encoding: 8bit
";
$body = '';
if (is_array($var) || is_object($var)) {
foreach ($var as $key => $value) {
$body .= $key . '<br />';
$body .= '<pre>';
$body .= print_r($value, true);
$body .= '<pre><br /><br />';
}
}
else {
$body = $var;
}
if (!module_exists('mimemail')) {
mail($to, $subject, $body, $mail);
}
else {
mimemail(variable_get('site_mail', ''), $to, $subject, $body);
}
}
