You are here

function mandrill_template_mandrill_mail_alter in Mandrill 7

Same name and namespace in other branches
  1. 7.2 modules/mandrill_template/mandrill_template.module \mandrill_template_mandrill_mail_alter()

Implements hook_mandrill_mail_alter().

Determine if an email is configured to use a Mandrill template and change the mandrill_send_function parameter as needed.

File

modules/mandrill_template/mandrill_template.module, line 152
Enables Drupal to send email using Mandrill's template system.

Code

function mandrill_template_mandrill_mail_alter(&$mandrill_params, $message) {
  $template_map = mandrill_template_map_load_by_mailsystem($message['id']);
  if ($template_map) {
    $mandrill_params['function'] = 'mandrill_template_sender';
    $mandrill_params['args'] = array(
      'template_id' => $template_map->template_id,
      'template_content' => array(
        array(
          'name' => $template_map->main_section,
          'content' => $message['body'],
        ),
      ),
    );
    if (isset($message['mandrill_template_content'])) {
      $mandrill_params['args']['template_content'] = array_merge($message['mandrill_template_content'], $mandrill_params['args']['template_content']);
    }
  }
}