2

There are several modules that send email from my site: Rules, Trigger, User, ...

I am looking for a place to set a drupal_set_message() and print out the email contents. Where in the code would be the best place for that?

7

You can use hook_mail_alter() to get (and alter) the contents of an e-mail message before it gets sent out:

function mymodule_mail_alter(&$message) {
  dpm($message);
}

One thing to keep in mind is that not all modules use drupal_mail(), the function that'll call hook_mail_alter(), for various reasons. In that case, you'll have to identify where in the module's code the mail is sent out and see if they provide their own alter hooks: look for the functions drupal_alter('foo') (implemented via hook_foo_alter()), module_implements('foo'), module_invoke('foo'), or module_invoke_all('foo') (all implemented by hook_foo()).

Failing that, you may have to temporarily add the dpm() call directly to the module in the right place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.