Logging emails in drupal 6

Ever tried to log all your email?
People come up with the craziest ideas to log email but luckely in drupal there is a nice way to log your emails to a file in your system.

I'm currently using it only for debugging but here it goes!

ps: Don't forget to replace your_module_name with, well yeah, your module name!
Requirement : Devel module
Location of log file : /tmp/drupal_debug.txt

/**
* Implementation of hook_mail_alter().
*
* @param $message A structured array containing the message to be altered. keys in this array include: id, to, subject, body, from, headers
*/
function your_module_name_mail_alter(&$message) {

dd($message);
}

1 comments on Logging emails in drupal 6

  1. Jo Wouters (not verified)
    Thu, 11/19/2009 - 19:09

    Mmm, that's even easier than the solutions given by Acquia (see http://acquia.com/blog/spam-yourself-spamalot-or-spamalittle-develmaillog) and Chx (see my comment) !

  2. Post new comment

    The content of this field is kept private and will not be shown publicly.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
    • Lines and paragraphs break automatically.

    More information about formatting options