You are here

function views_send_deliver in Views Send 8

Same name and namespace in other branches
  1. 6 views_send.cron.inc \views_send_deliver()
  2. 7 views_send.module \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 850
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(
    'to' => $message->to_mail,
    'from' => $message->from_mail,
    'subject' => $message->subject,
    'body' => $message->body,
    'headers' => $headers,
  );

  // Adding attachments explicitly because Swift Mailer and Mandrill doesn't
  // handle attachments in the format function. Only works for batch delivery of mail.
  if (!empty($message->params) && (\Drupal::moduleHandler()
    ->moduleExists('swiftmailer') || \Drupal::moduleHandler()
    ->moduleExists('mandrill'))) {
    $mail['params'] = $message->params;
  }
  $system = $mail_backend = \Drupal::service('plugin.manager.mail')
    ->getInstance(array(
    'module' => 'views_send',
    'key' => $key,
  ));
  return $system
    ->mail($mail);
}