You are here

static function Messaging_Mail_Method::mail_headers in Messaging 7

Same name and namespace in other branches
  1. 6.3 classes/messaging_method.class.inc \Messaging_Mail_Method::mail_headers()

Get mail headers. Helper function for mail methods

Parameters

$params: Array of parameters with the following elements

  • 'from', Mail from address
  • 'default_from', Default from address
  • 'headers', Predefined headers to be added to this one
3 calls to Messaging_Mail_Method::mail_headers()
Messaging_HTML_Mail_Method::mail_build in messaging_htmlmail/messaging_htmlmail.inc
Rebuild message in Drupal mail format, right before sending
Messaging_Mail_Method::mail_build in messaging_mail/messaging_mail.inc
Rebuild message in Drupal mail format, right before sending
Messaging_Mail_Method::mail_params in messaging_mail/messaging_mail.inc
Prepare from address and mail headers

File

messaging_mail/messaging_mail.inc, line 182
Drupal Messaging Framework - Send_Method class file

Class

Messaging_Mail_Method
Base class for mail sending methods

Code

static function mail_headers($message, $params = array()) {
  $headers = !empty($params['headers']) ? $params['headers'] : array();

  // Add some default headers
  $headers += array(
    'MIME-Version' => '1.0',
    'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
    'Content-Transfer-Encoding' => '8Bit',
    'X-Mailer' => 'Drupal',
  );
  $default_from = $params['default_from'];
  $from = !empty($params['from']) ? $params['from'] : $default_from;

  // Set default headers depending on data
  $headers += array(
    'From' => $from,
    'Reply-To' => $from,
  );
  if ($params['returnpath']) {

    // To prevent e-mail from looking like spam, the addresses in the Sender and
    // Return-Path headers should have a domain authorized to use the originating
    // SMTP server. Errors-To is redundant, but shouldn't hurt.
    $more_headers['Sender'] = $more_headers['Return-Path'] = $more_headers['Errors-To'] = $params['returnpath'];
    $headers += $more_headers;
  }
  return $headers;
}