You are here

function messaging_mail_headers in Messaging 6.3

Same name and namespace in other branches
  1. 6 messaging.mail.inc \messaging_mail_headers()
  2. 6.2 messaging.mail.inc \messaging_mail_headers()

Get mail headers. Helper function for mail methods

1 call to messaging_mail_headers()
messaging_mail_prepare in ./messaging.mail.inc
Rebuild message in Drupal mail format

File

./messaging.mail.inc, line 64
Common library for mail methods

Code

function messaging_mail_headers($message, $params) {
  $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 = variable_get('site_mail', ini_get('sendmail_from'));
  $from = !empty($params['from']) ? $params['from'] : $default_from;

  // Set default headers depending on data
  $headers += array(
    'From' => $from,
    'Reply-To' => $from,
  );
  if ($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'] = $default_from;
    $headers += $more_headers;
  }
  return $headers;
}