Drupal 7
$my_module = 'foo';
$my_mail_token = 'bar';
$from = variable_get('system_mail', 'info@test.net');
$message = array(
'id' => $my_module . '_' . $my_mail_token,
'to' => 'debug@test.net',
'subject' => 'Prueba de envío',
'body' => array('test'),
'headers' => array(
'From' => $from,
'Sender' => $from,
'Return-Path' => $from,
),
);
$system = drupal_mail_system($my_module, $my_mail_token);
// The format function must be called before calling the mail function.
$message = $system->format($message);
if ($system->mail($message)) {
// Success.
}
else {
// Failure.
}
Drupal 6
$message['id'] = 'testing';
$message['to'] = 'direccion@mail.net';
$message['subject'] = 'TEST3';
$message['body'] = 'Cuerpo';
$message['headers'] = array();
drupal_mail_send($message);