How to programmatically send an email? I'd like to use Drupal's email system to programmatically send an email from my custom module. Is that possible?
Using hook_mail and drupal_mail you can create and send an e-mail.

Implement an e-mail use hook_mail:

function MODULENAME_mail ($key, &amp;$message, $params) {
  switch ($key) {
    case 'mymail':
      // Set headers etc
      $message['to'] = 'foo@bar.com';
      $message['subject'] = t('Hello');
      $message['body'][] = t('Hello @username,', array('@username' =&gt; $params['username']));
      $message['body'][] = t('The main part of the message.');
      break;
  }
}


To send a mail use drupal_mail:

drupal_mail($module, $key, $to, $language, $params = array('username' =&gt; 'John Potato'), $from = NULL, $send = TRUE)


Obviously replace the parameters: $key should equal 'mymail'

An e-mail is sent in a few steps:


drupal_mail is called 
Drupal builds the e-mail 
hook_mail is called for the specifics (implementation) 
hook_mail_alter is called so other modules can modify it 
drupal_send_mail is called