You are here

devel_mail_logger_civicrm.module in Devel Mail Logger 7

File

devel_mail_logger_civicrm/devel_mail_logger_civicrm.module
View source
<?php

/**
 * Implements hook_cvicrm_alterMailParams().
 */
function devel_mail_logger_civicrm_civicrm_alterMailParams(&$params, $context) {

  //  We abort the sending and copy it as a simple drupal send so that the core module can handle rest
  if ($context == 'singleEmail') {
    $drupal_mail_params = array(
      'subject' => $params['subject'],
      'body' => array(
        isset($params['html']) ? $params['html'] : $params['text'],
      ),
    );
    if (isset($params['bcc'])) {
      $drupal_mail_params['bcc'] = $params['bcc'];
    }
    if (isset($params['headers'])) {
      $drupal_mail_params['headers'] = $params['headers'];
    }
    drupal_mail('devel_mail_logger_civicrm', 'devel_mail_logger_civicrm_email', $params['toEmail'], LANGUAGE_NONE, $drupal_mail_params, $params['from']);
    $params['abortMailSend'] = TRUE;
  }
}

/**
 * Implements hook_mail().
 */
function devel_mail_logger_civicrm_mail($key, &$message, $params) {
  switch ($key) {
    case 'devel_mail_logger_civicrm_email':
      $message['subject'] = $params['subject'];
      $message['body'] = $params['body'];
      break;
  }
}

Functions

Namesort descending Description
devel_mail_logger_civicrm_civicrm_alterMailParams Implements hook_cvicrm_alterMailParams().
devel_mail_logger_civicrm_mail Implements hook_mail().