You are here

function devel_mail_logger_mail_alter in Devel Mail Logger 7

Implements hook_mail_alter().

File

./devel_mail_logger.module, line 91

Code

function devel_mail_logger_mail_alter(&$message) {
  if (!isset($message['from_devel_mail_logger']) || !$message['from_devel_mail_logger']) {
    $message['send'] = FALSE;
    $record = array(
      'timestamp' => REQUEST_TIME,
      'recipient' => $message['to'],
      'subject' => $message['subject'],
      'message' => json_encode($message),
    );
    if (drupal_write_record('devel_mail_logger', $record) == SAVED_NEW) {
      drupal_set_message(t('Email logged to database'));
    }
    else {
      drupal_set_message(t('Attempt to save email to database failed'), 'error');
    }
  }
}