drupal_mail() strips all html tags from emails So as the title explains, when sending an HTML email with drupal_mail(), email comes with no HTML tags.

    $module = 'module';
    $key = 'contact_message';
    $language = language_default();
    $params = array();
    $email = 'sender@email.com';
    $from = variable_get('site_mail', 'admin@example.com');
    $send = TRUE;
    $message = drupal_mail($module, $key, $email, $language, $params, $from, $send);
    $message['headers']['Content-Type'] = 'text/html; charset=UTF-8';
    $message['subject'] = 'Test';
    $message['body'] = array();
    $message['body'][] = '&lt;a href="#"&gt;Testing anchor in mail&lt;/a&gt;';
    $system = drupal_mail_system($module, $key);
    $message = $system-&gt;format($message);
    $message['result'] = $system-&gt;mail($message);


And when recieving the email, and viewing the source:

Message-Id: &lt;201305090722.r497MLAV005654@test.server&gt;
X-Authentication-Warning: testserver : www-data set sender to sender@email.com using -f
To: from@email.com
Subject: Test
X-PHP-Originating-Script: 1000:system.mail.inc
MIME-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
Sender: sender@email.com
From: from@email.com

Testing anchor in mail [1]

[1] #


So you can see that any HTML tags were stripped.
And it doesn't matter what HTML tags I put in body.

I thought it might be related to Text Fomats, but I have "Filtered HTML" and "Full HTML" active filters with any permissions.



The thing confused me were the Ubercart invoices. At first they were sent with HTML, and then at some point it stopped. They were received plain text.
After digging a bit @develkar answer, I've found this in one of ubercart updates:

/**
 * Installs HTML Mail System for Ubercart.
 */
function uc_store_update_7004() {
  // Set mail handler for all Ubercart modules
  variable_set('mail_system',
    array_merge(
      variable_get('mail_system', array('default-system' =&gt; 'DefaultMailSystem')),
      array(
        'uc_cart'  =&gt; 'UbercartMailSystem',
        'uc_order' =&gt; 'UbercartMailSystem',
        'uc_file'  =&gt; 'UbercartMailSystem',
        'uc_roles' =&gt; 'UbercartMailSystem',
        'uc_stock' =&gt; 'UbercartMailSystem',
        'uc_store' =&gt; 'UbercartMailSystem',
      )
    )
  );
}


I guess that at some point, one of installed modules (I suspect SMTP module) overridden this variable, and that's why emails were coming plain text.
After running this update manually again, Ubercat invoices are HTML again.

For the rest of emails, I'll have to install some modules as suggested in other answers.

Thanx.
drupal_mail(), by default sends a mail as plain text.

If you print out the array $message['headers'], you will get something like:

array(
    'MIME-Version' =&gt; '1.0',
    'Content-Type' =&gt; 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
    'Content-Transfer-Encoding' =&gt; '8Bit',
    'X-Mailer' =&gt; 'Drupal',
  );


As you can see, the Content-Type in the mail header is text/plain; charset=UTF-8; format=flowed; delsp=yes. You can try by modifying this header in hook_mail_alter(), you could use one of the modules which allows you to send the mail as HTML, like HTML Mail, or Mime Mail.

Edit:

Following the comments by @Ayesh and @alechko and after looking into the APIs, I found out that the headers are not the only reason for sending the mail as plain text. Because drupal_mail() internally makes a call to drupal_mail_system(), which returns an object that implements the MailSystemInterface interface. The format() method implemented by drupal_mail_system() is responsible for stripping out the HTML from the emails. So, even if the headers of the mail show the formats to be HTML, the mails would be sent as plain text only. So, I guess one could not send an HTML mail using drupal_mail(). You should look for some other alternative (module) mentioned above.