Experimental project

This is a sandbox project, which contains experimental code for developer use only.

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', '') . ">\n";
  $mail .= "Content-Type: text/html\n Content-Transfer-Encoding: 8bit\n";

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

Project information

  • caution Maintenance fixes only
    Considered feature-complete by its maintainers.
  • Project categories: Developer tools
  • Created by yannickoo on , updated