- πΊπΈUnited States jphelan
This seems to work for me to conditionally set it for emails containing HTML.
/** * Implement hook_mail_alter(). */ function my_module_mail_alter(&$message) { //test if message body contains html tags if (preg_match('/<[^>]*>/', $message['params']['message'])) { // Set the content type to HTML $message['headers']['Content-Type'] = 'text/html'; } }