You are here

function views_send_deliver in Views Send 7

Same name and namespace in other branches
  1. 8 views_send.module \views_send_deliver()
  2. 6 views_send.cron.inc \views_send_deliver()

Sending a prepared message.

Return value

Boolean indicating if the message was sent successfully.

2 calls to views_send_deliver()
views_send_batch_deliver in ./views_send.module
Preparing and sending a message (coming from a batch job).
views_send_send_from_spool in ./views_send.cron.inc
Process the spool queue at cron run.

File

./views_send.module, line 1149
The Views Send module.

Code

function views_send_deliver($message) {
  if (is_array($message)) {
    $message = (object) $message;
  }
  $key = 'direct';
  $headers = unserialize($message->headers);
  $mail = array(
    'id' => 'views_send_' . $key,
    'module' => 'views_send',
    'key' => $key,
    'to' => $message->to_mail,
    'from' => $message->from_mail,
    'subject' => $message->subject,
    'body' => $message->body,
    'headers' => $headers,
  );
  if (!empty($message->params)) {

    // Adding attachments explicitly because Swift Mailer and Mandrill doesn't
    // handle attachments in the format function. Only works for batch delivery of mail.
    if (module_exists('swiftmailer') || module_exists('mandrill')) {
      $mail['params'] = $message->params;
    }
  }

  // Mime encode the subject before passing to the mail function
  // to work around a bug in Drupal's mime_header_encode.
  $mail['subject'] = _views_send_mime_header_encode($message->subject);
  $system = drupal_mail_system('views_send', $key);
  return $system
    ->mail($mail);
}