You are here

public function HTMLMailMailSystem::mail in HTML Mail 7

Send an email message.

Overrides MailSystemInterface::mail

File

./htmlmail.mail.inc, line 86
Implementation of MailSystemInterface.

Class

HTMLMailMailSystem
@file Implementation of MailSystemInterface.

Code

public function mail(array $message) {
  $mimeheaders = array();
  foreach ($message['headers'] as $name => $value) {
    $mimeheaders[] = $name . ': ' . mime_header_encode($value);
  }
  if (isset($message['headers']['Return-Path']) && !ini_get('safe_mode') && !strpos(ini_get('sendmail_path'), ' -f')) {
    $extra = '-f ' . $message['headers']['Return-Path'];
  }
  else {
    $extra = '';
  }

  // To override this, adjust $conf['mail_line_endings'] in settings.php.
  $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
  return mail($message['to'], str_replace("\n", ' ', mime_header_encode($message['subject'])), preg_replace('@\\r?\\n@', $line_endings, $message['body']), join("\n", $mimeheaders), $extra);
}