You are here

function mail_logger_mail_logger in Mail Logger 7

Same name and namespace in other branches
  1. 6 mail_logger.module \mail_logger_mail_logger()

Implements hook_mail_logger().

File

./mail_logger.module, line 191
Mail Logger module logs all outgoing mail that passes through the drupal_mail function.

Code

function mail_logger_mail_logger($op, $message, $sender = NULL, $recipient = NULL) {

  // We only act on the 'mail_sent' action/rule.
  if (!in_array($op, array(
    'mail_sent',
  ))) {
    return;
  }
  if (module_exists('trigger')) {

    // First we trigger the action.
    $aids = trigger_get_assigned_actions('mail_logger');
    $context = array(
      'hook' => 'mail_logger',
      'op' => $op,
      'message' => $message,
      'sender' => $sender,
      'recipient' => $recipient,
    );
    actions_do(array_keys($aids), $message, $context);
  }

  // If the Rules module has been installed, then also trigger the defined rule.
  if (module_exists('rules')) {
    global $user;
    rules_invoke_event('mail_logger_mail_sent', $message, $sender, $recipient, $user);
  }
}