Commit b5674375 authored by webchick's avatar webchick

#239825 by jeffschuler and bjaspan: Add support for OS-specific line endings on e-mails.

parent 7353d5da
......@@ -6,6 +6,12 @@
* API functions for processing and sending e-mail.
*/
/**
* Auto-detect appropriate line endings for e-mails.
* $conf['mail_line_endings'] will override this setting.
*/
define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE ? "\r\n" : "\n");
/**
* Compose and optionally send an e-mail message.
*
......
......@@ -45,12 +45,13 @@ public function mail(array $message) {
foreach ($message['headers'] as $name => $value) {
$mimeheaders[] = $name . ': ' . mime_header_encode($value);
}
$line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
return mail(
$message['to'],
mime_header_encode($message['subject']),
// Note: e-mail uses CRLF for line-endings, but PHP's API requires LF.
// They will appear correctly in the actual e-mail that is sent.
str_replace("\r", '', $message['body']),
// Note: e-mail uses CRLF for line-endings. PHP's API requires LF
// on Unix and CRLF on Windows. See mail_line_endings in settings.php.
preg_replace('@\r?\n@', $line_endings, $message['body']),
// For headers, PHP's API suggests that we use CRLF normally,
// but some MTAs incorrectly replace LF with CRLF. See #234403.
join("\n", $mimeheaders)
......
......@@ -166,6 +166,15 @@
*/
$update_free_access = FALSE;
/**
* Line endings for e-mail messages
*
* Drupal automatically guesses the line-ending format appropriate for your
* system. If you need to override this, uncomment the statement below and set
* it to the line-ending string of your choice.
*/
# $conf['mail_line_endings'] = "\r\n";
/**
* Base URL (optional).
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment