You are here

protected function Messaging_Mail_Method::mail_params in Messaging 7

Prepare from address and mail headers

1 call to Messaging_Mail_Method::mail_params()
Messaging_Mail_Method::message_prepare in messaging_mail/messaging_mail.inc
Add specific mail parameters to message

File

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

Class

Messaging_Mail_Method
Base class for mail sending methods

Code

protected function mail_params($message, $params = array()) {

  // The message 'from' will depend on message sender if present, otherwise default to site mail
  if (empty($params['from'])) {
    $sender_name = $message
      ->get_sender_name();
    $sender_account = $message
      ->get_sender_account();
    if ($sender_name && $sender_account && !empty($sender_account->mail)) {
      $from = $this
        ->format_from($sender_name, $sender_account->mail);
    }
    elseif ($sender_name) {
      $from = $this
        ->format_from($sender_name, $params['default_from']);
    }
    else {
      $from = $params['default_from'];
    }
    $params['from'] = $from;
  }
  else {
    $from = $params['from'];
  }
  $params += array(
    'from' => $from,
    'headers' => array(),
  );

  // Set headers, or add to existing ones. Pre-existing ones should not be overridden.
  $headers = $this
    ->mail_headers($message, $params);
  $params['headers'] += $headers;
  return $params;
}