Add attachments to mail How I send a mail with attachments using the mimemail module? In drupal 6 it was using the function:

mimemail($sender, $recipient, $subject, $body, $plaintext = NULL, $headers = array(), $text = NULL, $attachments = array(), $mailkey = '', $send = TRUE)


But I am not able to figure out how to do this in drupal 7.
Try this code. I'm using it with backup and migrate module

$module = 'backup_migrate';
$key = microtime();
$language = language_default();
$params = array();
$params['attachments'][] = array(
  'filepath' =&gt; $attachment-&gt;path,
  'filecontent' =&gt; 'My attachment.',
  'filename' =&gt; $attachment-&gt;filename,
  'filemime' =&gt; 'text/plain',
);

$from = $mail-&gt;from;

$send = FALSE;
$message = drupal_mail($module, $key, $to, $language, $params, $from, $send);

$message['subject'] = t('Database backup from !site: !file', array('!site' =&gt; variable_get('site_name', 'drupal'), '!file' =&gt; $attachment-&gt;filename));
$message['body'] = t('Database backup attached.') ."\n\n";

// 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);