drupal_mail_system is returning empty object I have installed mime module for sending html mails. Im receiving Drupal security update on my site but not sending/receiving any mails through my code.

$settings = array(
  'id' =&gt; $my_module . '_' . $my_mail_token,
  'to' =&gt; $email_to,
  'subject' =&gt; $email_subject,
  'body' =&gt; $email_message,
  'headers' =&gt; array(
    'From' =&gt; $conf['FROM_email'],
    'Sender' =&gt; $FROM,
    'Return-Path' =&gt; $FROM,
    'Content-Type' =&gt; 'text/html; charset=UTF-8; format=flowed',
  ),
);


$system = drupal_mail_system($my_module, $my_mail_token);
if ($system-&gt;mail($settings)) {
  print 'success';
}
else {
  print 'failed';
}


I tried to print_r($system) which is supposed to return object of mail system interface but all I received was HTMLMailSystem Object ( ). What am I missing?
You forgot to call format method.

Try the following snippet:

$from = variable_get('system_mail', $my_email);
$message = array(
  'id' =&gt; $my_module . '_' . $my_mail_token,
  'to' =&gt; $my_email,
  'subject' =&gt; $message_subject,
  'body' =&gt; array($message_body),
  'headers' =&gt; array(
    'From' =&gt; $from,
    'Sender' =&gt; $from,
    'Return-Path' =&gt; $from,
  ),
);
$system = drupal_mail_system($my_module, $my_mail_token);

// The format function must be called before calling the mail function. 
$message = $system-&gt;format($message);

if ($system-&gt;mail($message)) {
  drupal_set_message('SUCCESS');
}
else {
  drupal_set_message('FAILURE');
}