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.
Comment | File | Size | Author |
---|---|---|---|
mail_0.patch | 4.84 KB | Dave Cohen |
Comments
Comment #1
Dave Cohen CreditAttribution: Dave Cohen commentedJust changing status to reflect that there is a patch.
Comment #2
zerolab CreditAttribution: zerolab at Torchbox commented