As you are using HOOK_node_insert() in your module then you can do anything in that function. As the previous answer, its better to use hook_theme(). So once you call the hook_node_insert() you can call a custom function and that will have the return type also that will send the email.
Follow the below mentioned steps,
- Create a new custom function as an example,
example_notify_subscribed($node_information)
In this function you can send the node informations. So here comes the hook_theme part.
- In the hook_theme() mention a new theme.
function your_module_theme($existing, $type, $theme, $path) {
if($type == 'module') {
'mail_node_notify' => array(
'variables' => array(
'node_information' => NULL,
'extra_vars' => NULL,
),
'template' => 'notify-mail-subs',
'path' => drupal_get_path('module', 'your_module').'/template',
),
);
}
}
- In your example_notify_subscribed function call this theme as following,
//Send the email
$email_text_user = theme('mail_node_notify', array(
'node_information' => $node, //Your node variable information
'extra_vars' => $extra, //If you send any more information to the template file
),
));
$email_values_user = array(
'module' => 'your_module',
'key' => 'mail_key', //Unique hook_mail key
'to' => $send_to,
'form' => variable_get('site_mail', '[email protected]'),
'subject' => t('Your subject'),
'body' => $email_text_user,
);
$sent_to_user = your_module_mail_send($email_values_user); //Custom Function to send email (HTML)
You may need to create some hook_mail_alter() and a new class to extend default DefaultMailSystem Class from Drupal. Because Drupal 7 by default sends text emails.
I hope this idea helps.