I'm trying to send HTML email from a module. I'm using the drupal_mail function to send the emails.

It's not possible to send HTML email with just drupal_mail (see here), and I've installed Mimemail. However the email is still being stripped of all HTML tags.

Do I need to make any extra calls in the email template, or is there something else I've forgotten?


Mail System

  • format() -- mimemail system
  • mail() -- SMTP module


  • Email Format: Filtered HTML (My filtered HTML allows <p> and <br> tags.
  • Include all site stylesheets.

SMTP module

  • Allow HTML formatted emails


tellafriend_mail($key, &$message, $params) {

  $message['headers']['MIME-Version'] = '1.0';
  $message['headers']['Content-Type'] = 'multipart/mixed;';
  $message['headers']['Content-Type'] = 'text/html;';
  $message['subject'] = t('This is a test email');

  $message['body'][] = t("This is a test email")."<p></p><p>".t("This should be a new paragraph.")."</p><p></p><p>".t("And a third paragraph.")."</p>";
  $message['params']['attachments'] = $params; 
  • this can be an off-topic comment, but you can use SwiftMailer Library (from Fabien Potencier) for extended mailing purposes.. – xurshid29 Dec 17 '13 at 13:07

As it turns out HTML email was infact enabled. The problem was the stylesheets that the email was being bundled with.

If you head to admin/config/system/mimemail you can choose to either bundle the email with your website stylesheets, or set-up a mail.css in your default theme directory.

I suspect if you're using a sub-theme and haven't got mail.css it'll just use the original theme mail.css which is probably not what you want.

| improve this answer | |
  • "if you're using a sub-theme and haven't got mail.css it'll just use the original theme mail.css" This does not appear to be the case at present. Unless we've got our subthemes set up wrong, that is. – KingAndy Oct 4 '17 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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