You are here

function mandrill_prepare_message in Mandrill 7.2

Runs the message through the theming system, and produces the correct plain-text message that will be fed to Mandrill.

1 call to mandrill_prepare_message()
MandrillHtmlMailSystem::format in lib/mandrill.mail.inc
Concatenate and wrap the email body for either plain-text or HTML emails.

File

./mandrill.module, line 370
Enables Drupal to send email directly through Mandrill.

Code

function mandrill_prepare_message($message) {
  $module = $message['module'];
  $key = $message['key'];
  $to = $message['to'];
  $subject = $message['subject'];
  $body = $message['body'];
  $hook = [
    'mandrill_message__' . $key,
    'mandrill_message__' . $module . '__' . $key,
  ];
  $variables = [
    'module' => $module,
    'key' => $key,
    'recipient' => $to,
    'subject' => $subject,
    'body' => $body,
  ];
  $message['params']['plaintext'] = drupal_html_to_text($body);
  $message['body'] = theme($hook, $variables);
  return $message;
}