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?


You can use hook_mail_alter() to get, or alter, the content of an e-mail message before it's sent out.

function mymodule_mail_alter(&$message) {

Not all modules use drupal_mail(), which means that for those modules hook_mail_alter() won't be invoked when they send an email.
In this case, you need to identify where in the module's code the mail is sent out, and see if they provide their own alter hooks. Look for any call to drupal_alter(), module_implements(), module_invoke(), or module_invoke_all().

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.