You are here

function Messaging_Mail_Method::mail_headers in Messaging 6.3

Same name and namespace in other branches
  1. 7 messaging_mail/messaging_mail.inc \Messaging_Mail_Method::mail_headers()

Get mail headers. Helper function for mail methods

1 call to Messaging_Mail_Method::mail_headers()
Messaging_Mail_Method::message_prepare in classes/messaging_method.class.inc
Rebuild message in Drupal mail format

File

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

Class

Messaging_Mail_Method
Base class for mail sending methods

Code

function mail_headers($message) {
  $headers = !empty($message->params['headers']) ? $message->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',
  );
  $from = !empty($message->params['from']) ? $message->params['from'] : $this->default_from;

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

    // 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'] = $this->default_from;
    $headers += $more_headers;
  }
  return $headers;
}