fn_send_mail hook question

I need to write a CODE hook that will take the $body variable from fn_send_mail and do some formatting/cleaning up to it before the emails are sent. I noticed in fn.common.php there is

a hook called send_mail_pre I could use.

If I add the below to my add ons functions.php file will this do what i need. I mean to say will the formatted version of body be used when sending the emails?

function fn_myaddon_send_mail_pre ($body)


$body = format($body);


any help is greatly appreciated!

The body takes a template filename as an argument.

Why don't you just modify the template to be how you want it.

To do what you want to do, you also have to register_hooks() in your init.php in your addon so it knows to look for your function.

thanks for the feedback but i am using includes for header, stylesheet etc… in my emails. since gmail cant read styles in the head i have a php script that moves all styles in the head to true inline in the html source. my only solution thus far has been to manually edit functions.php function fn_attach_images and added a function at the end that uses tidy to clena up the html source and another function that moves the styles to inline such as becomes

Gmail can't read embedded styles? Since when? Pretty standard HTML specification.

I have no idea what you're doing so probably can't be of much assistance. But regardless, the fn_send_mail() function does expect the subject and body parameters to be the names of template files.