You are here

function Messaging_Mail_Method::message_presend in Messaging 6.3

Message ready for sending, invoke mail alter

File

classes/messaging_method.class.inc, line 385
Drupal Messaging Framework - Send_Method class file

Class

Messaging_Mail_Method
Base class for mail sending methods

Code

function message_presend($message) {
  $mail = array(
    'id' => 'messaging_' . (!empty($message->type) ? 'message-' . $message->type : 'message'),
    'to' => $message->destination,
    'from' => $message->params['from'],
    'language' => $message
      ->get_language(),
    'params' => $message->params,
    'subject' => $message->subject,
    'body' => $message->body,
    'headers' => $message->params['mail_headers'],
    'attachments' => !empty($message->files) ? $message->files : array(),
  );

  // Invoke hook_mail_alter()
  drupal_alter('mail', $mail);

  // Rebuild message with results
  $message->destination = $mail['to'];
  $message->params = $mail['params'];
  $message->params['from'] = $mail['from'];
  $message->params['mail_headers'] = $mail['headers'];
  $message->subject = $mail['subject'];
  $message->body = $mail['body'];

  // Other parts are not suppossed to change, like language, files
}