You are here

public function MailgunMailSystem::format in Mailgun 7

Concatenate and wrap the e-mail body for either plain-text or HTML e-mails.

Parameters

array $message: A message array, as described in hook_mail_alter().

Return value

array The formatted $message.

Overrides MailSystemInterface::format

File

./mailgun.mail.inc, line 22
Implements Mailgun as a Drupal MailSystemInterface.

Class

MailgunMailSystem
Modify the Drupal mail system to use Mailgun when sending e-mails.

Code

public function format(array $message) {

  // Join the body array into one string.
  if (is_array($message['body'])) {
    $message['body'] = implode("\n\n", $message['body']);
  }

  // Run the message through text format if specified in Mailgun settings.
  $format = variable_get('mailgun_format', '_none');
  if ($format !== '_none') {
    $message['body'] = check_markup($message['body'], $format);
  }

  // Wrap body with theme function.
  $message['body'] = theme('mailgun_message', array(
    'subject' => $message['subject'],
    'body' => $message['body'],
    'message' => $message,
  ));
  return $message;
}