I have a node type I'd like to send out via email, but I theme the node in a way that varies depending on the user viewing it. So I needed a way to theme the mail message depending on who is receiving it. Attached is a patch that works for me so far.

The main change is this: instead of relying on node_view() to get the message body, I call a new hook, hook_view_mail(). If not found, the behavior defaults to the original (node_view()). If hook_view_mail() is implemented, it is passed the node, account of the recipient, and the mail format.

I've made a couple changes which were not necessary for this feature, but make the mail module work better for me. In particular theme_mail_message() now also takes the recipient account, and I moved the logic of plain vs html from _mail_dispatch() into theme_mail_message().

This patch addresses http://drupal.org/node/25502 and http://drupal.org/node/15901 as well. (Sorry to include so much in a single patch).

I think it would be great if these changes made it into the module, but if not I just want to share what works for me. Thanks for a great module.

CommentFileSizeAuthor
mail_0.patch4.84 KBDave Cohen
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Cohen’s picture

Status: Active » Needs review

Just changing status to reflect that there is a patch.

zerolab’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)