Debugging emails

Public

First approach is by using devel.module. Just add these lines to your settings.php. All emails will be logged in to your tmp directory.

Get raw version
php
  1. $conf['mail_system'] = array(
  2. 'default-system' => 'DevelMailLog',
  3. );

Second approach is to put this snippet into your custom module. You'll get a whole message object printed out on your screen.

Get raw version
php
  1. /**
  2.  * Implements hook_mail_alter().
  3.  */
  4. function module_name_mail_alter(&$message) {
  5. dpm($message);
  6. // Uncomment the next line to prevent Drupal from sending out messages.
  7. // $message['to'] = '';
  8. }