I know that it may be late, but it can help others. It is better to use drupal_mail and then set the headers in hook_mail instead of hook_mail alter. An example would look like this:
/*drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) Lets say we call drupal_mail from somewhere in our code*/ $params = array( 'subject' => t('Client Requests Quote'), 'body' => t("Body of the email goes here"), ); drupal_mail("samplemail", "samplemail_html_mail", " admin@mysite.com ", language_default(), $params, " admin@mysite.com "); /*We now setup our mail format, etc in hook mail*/ function hook_mail($key, &$message, $params) { case 'samplemail_html_mail': /* * Emails with this key will be HTML emails, * we therefore cannot use drupal default headers, but set our own headers */ /* * $vars required even if not used to get $language in there since t takes in: t($string, $args = array(), $langcode = NULL) */ $message['subject'] = t($params['subject'], $var, $language->language); /* the email body is here, inside the $message array */ $body = "<html><body> <h2>HTML Email Sample with Drupal</h2> <hr /><br /><br /> {$params['body']} </body></html>"; $message['body'][] = $body; $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed'; break; }
If this is not clear to you, a complete tutorial on this subject can be found on My Blog
Hope this helps
Jk
source share