You are here

function _views_send_headers in Views Send 7

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

Build header array with priority and receipt confirmation settings.

Parameters

$receipt: Boolean: If a receipt is requested.

$priority: Integer: The message priority.

$from: String: The sender's e-mail address.

Return value

Header array with priority and receipt confirmation info

2 calls to _views_send_headers()
views_send_confirm_form in ./views_send.module
Multistep form callback for the "confirm" step. Allows the user to preview the whole message before sending it.
views_send_queue_mail in ./views_send.module
Assembles the email and queues it for sending.

File

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

Code

function _views_send_headers($receipt, $priority, $from, $additional_headers) {
  $headers = array();

  // If receipt is requested, add headers.
  if ($receipt) {
    $headers['Disposition-Notification-To'] = $from;
    $headers['X-Confirm-Reading-To'] = $from;
  }

  // Add priority if set.
  switch ($priority) {
    case VIEWS_SEND_PRIORITY_HIGHEST:
      $headers['Priority'] = 'High';
      $headers['X-Priority'] = '1';
      $headers['X-MSMail-Priority'] = 'Highest';
      break;
    case VIEWS_SEND_PRIORITY_HIGH:
      $headers['Priority'] = 'urgent';
      $headers['X-Priority'] = '2';
      $headers['X-MSMail-Priority'] = 'High';
      break;
    case VIEWS_SEND_PRIORITY_NORMAL:
      $headers['Priority'] = 'normal';
      $headers['X-Priority'] = '3';
      $headers['X-MSMail-Priority'] = 'Normal';
      break;
    case VIEWS_SEND_PRIORITY_LOW:
      $headers['Priority'] = 'non-urgent';
      $headers['X-Priority'] = '4';
      $headers['X-MSMail-Priority'] = 'Low';
      break;
    case VIEWS_SEND_PRIORITY_LOWEST:
      $headers['Priority'] = 'non-urgent';
      $headers['X-Priority'] = '5';
      $headers['X-MSMail-Priority'] = 'Lowest';
      break;
  }

  // Add general headers.
  $headers['Precedence'] = 'bulk';

  // Add additional headers.
  $additional_headers = trim($additional_headers);
  $additional_headers = str_replace("\r", "\n", $additional_headers);
  $additional_headers = explode("\n", $additional_headers);
  foreach ($additional_headers as $header) {
    $header = trim($header);
    if (!empty($header)) {
      list($key, $value) = explode(': ', $header, 2);
      $headers[$key] = trim($value);
    }
  }
  return $headers;
}