How to send HTML email I am creating a simple module which will be sending HTML emails to users for deals in our website.

I have searched a lot, but I can't find a solution proper solution for Drupal. Now I can send mails but plain text.

What is a step-by-step procedure to send HTML emails in Drupal 7?

function example_form_submit( $form,&amp;$form_state) {
    $friend_email=$form_state['values']['friend_email'];
    $mailto =$friend_email;  //gift to a friend
    $mailfrom ='no-reply@example.com';
    $subject = "another message for  HTML email from example.com";
    $body="&lt;h2 style='font-size:28px;color:red;'&gt;Hello EMAIL, i here i want to be &lt;b&gt;bolded&lt;/b&gt;&lt;/h2&gt;";
    if (drupal_mail('example', 'send_gift', $mailto, language_default(),$params,$mailfrom,TRUE)) {
        drupal_set_message(t('Your gift was sent successfully!!!'));
    }
    else {
        drupal_set_message(t('&lt;font color="red"&gt;Error occured while sending your mail!!!&lt;/font&gt;'));
    }


/****hook_mail*/
function example_mail($key,&amp;$message,$params) {
    $language = $message['language'];
    switch ($key) {
        case 'send_gift':
            $message['subject']=t($params['subject'], $var, $language-&gt;language);
            $message['body'][]=$params['body'];
            $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
        break;
    }
}
Like geoff mentioned one option would be to use the Mime Mail module, but you can also enable your custom module to send HTML e-mails with some extra code. In short you'd need to alter the mail_system variable and write your own implementation of MailSystemInterface. An example of that is the following code.

Inside 'mymodule.install':

function mymodule_enable() {
  $current = variable_get('mail_system', array('default-system' =&gt; 'DefaultMailSystem'));
  $addition = array('mymodule' =&gt; 'MymoduleMailSystem');
  variable_set('mail_system', array_merge($current, $addition));
}

function mymodule_disable() {
  $mail_system = variable_get('mail_system', array('default-system' =&gt; 'DefaultMailSystem'));
  unset($mail_system['mymodule']);
  variable_set('mail_system', $mail_system);
}


Inside 'mymodule.module':

class MymoduleMailSystem extends DefaultMailSystem {
  public function format(array $message) {
    $message['body'] = implode("\n\n", $message['body']);
    $message['body'] = drupal_wrap_mail($message['body']);
    return $message;
  }
}


You'd have to replace mymodule instances with your actual module's name then disable and re-enable your module to get the variable changed after which things should be working. For a complete example you can check out my answer here. Additionally this page on drupal.org is from where I originally got all the information from.