--- mass_contact.module Fri Apr 30 18:36:37 2010 +++ mass_contact.module Thu Dec 23 13:45:04 2010 @@ -1119,7 +1119,7 @@ $boundary_attachment = md5(uniqid(mt_rand())); $boundary_html = md5(uniqid(mt_rand())); - $character_set = (variable_get('mass_contact_character_set', '')) ? variable_get('mass_contact_character_set', '') : 'UTF-8'; + $character_set = variable_get('mass_contact_character_set', 'UTF-8'); $params = array(); $body_plain = ''; @@ -1260,7 +1260,20 @@ $message .= "\n--". $boundary_html ."\n"; $message .= "Content-Type: text/html; charset=$character_set; format=flowed\n"; $message .= "Content-Transfer-Encoding: 7bit\n\n"; - $message .= $body_html; + // If HTMLMail module exists, then create a 'dummy' data structure on which + // it can operate, explicitly call the mail alter, and then add the resulting + // body to the message. + if ( module_exists('htmlmail') ) { + $htmlmail_message = array( + 'headers' => array(), + 'body' => $body_html, + ); + htmlmail_mail_alter($htmlmail_message); + $message .= $htmlmail_message['body']; // use the HTML marked-up message + } + else { + $message .= $body_html; + } } } else { @@ -1602,7 +1615,7 @@ $file_path = file_save_data($file_data, $file_dest .'/'. $_FILES['files']['name']['attachment'], FILE_EXISTS_RENAME); $file_url = file_create_url($file_path); - $node_message = '
Attachment:
'. l($_FILES['files']['name']['attachment'], $file_url); + $node_message .= '
Attachment:
'. l($_FILES['files']['name']['attachment'], $file_url); } // Save the message as a node. @@ -1808,7 +1821,21 @@ } // Invoke hook_mail_alter() to allow all modules to alter the resulting e-mail. - drupal_alter('mail', $message); + // If HTMLMail module exists, then we've already had it operate on the HTML portion + // of the message in the form submit function, and we don't want it operating + // on the whole thing. So, mimic drupal_alter functionality with an HTMLMail + // bypass. + if ( module_exists('htmlmail') ) { + foreach ( module_implements('mail_alter') as $module ) { + if ( $module != 'htmlmail' ) { + $function = $module . '_mail_alter'; + call_user_func_array($function, array(&$message)); + } + } + } + else { + drupal_alter('mail', $message); + } // Removed destruction of multipart/mixed e-mails by the (now missing) call below