...
$file_content = file_get_contents('README.txt');
$attachments = array(
'filecontent' => $file_content,
'filename' => 'README',
'filemime' => 'text/plain',
);
drupal_mail(
'my_module',
'send_attachment',
'meil@gmail.com',
language_default(),
array(
'attachments' => $attachments
)
);
}
/**
* Implements hook_mail().
*/
function my_module_mail($key, &$message, $params) {
if ($key == 'send_attachment') {
$message['subject'] = 'Mail with attachment';
$message['body'][] = 'Body...';
}
}