I was unable to get HTML mail to use a template properly, so I have a mymodule_mail function that sends emails when a response is required from the user

function billiondollar_mail($key, &$message, $params) {
global $base_url;

$message['headers'] = array(
    'MIME-Version' => '1.0',
    'Return-Path' => '[email protected]',
    'Content-Type' => 'text/html; charset=UTF-8; format=flowed',
    'From' => 'XXXX <[email protected]>',
    'Content-Transfer-Encoding' => '8Bit',
    'X-Mailer' => 'Drupal'

I have a switch case on $key that loads in html header and footer plus the email body.

I'm wondering if there's some way I can make the system emails (some sent via trigger/actions and the registration confirmation ones) use that same system. Right now they are in plain text, which is incongruous with the rest of the system.

If I can get them using that hook function I will need to know what $key value it would have and how to insert the message content.. presumably one of the $params

1 Answer 1


I think this is what you're looking for:


"hook_mail_alter() allows modification of email messages created and sent with drupal_mail()... All core modules use drupal_mail() for messaging, it is best practice but not mandatory in contributed modules."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.