drupal_mail() sends two emails, second email is empty I'm using the following code for sending out an email with drupal_mail()

$module = 'example_module';
$key = 'key';
$language = language_default();
$params = array();
$from = 'email@email.com';
$send = TRUE;
$message = drupal_mail($module, $key, $order-&gt;mail, $language, $params, $from, $send);
$message['subject'] = 'Subject';
$message['body'] = $message_body;

// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);
// Format the message body.
$message = $system-&gt;format($message);
// Send e-mail.
$message['result'] = $system-&gt;mail($message);


I get two emails after the function that contains this runs, one email is perfect, the other email is completely empty.

The function that contains the code above only runs once, I tested by printing out some text with dsm().

How can I fix this?

Thank you!
The drupal_mail() function you call will send an email.

Then when you call $system-&gt;mail($message); that will send a second email.

Here is an example of how to use drupal_mail (taken from here):

/**
* Implements hook_entity_insert().
*
*/
function dummy_module_node_insert($node) {
  $module = 'dummy_module';
  $key = 'dummy_key';
  $language = language_default();
  $params = array(
    '@url' =&gt; url('node/' . $node-&gt;nid, array('absolute' =&gt; TRUE)),
    '@title' =&gt; $node-&gt;title,
  );

  drupal_mail($module, $key, $mail, $language, $params);
}

/**
* Implements hook_mail().
*/
function dummy_module_mail($key, &amp;$message, $params) {
  $message['subject'] = t("@title event registration confirmation", $params);
  $message['body'] = array();
  $message['body'][] = t("Hello", $params);
  $message['body'][] = t("Node has been created @title (@url).", $params);
}


The user who posted this code originally labeled it as "The propper way to use this:" and I've had success using this code before.