diff --git a/core/includes/mail.inc b/core/includes/mail.inc index 5e89917..d1cc647 100644 --- a/core/includes/mail.inc +++ b/core/includes/mail.inc @@ -8,9 +8,14 @@ /** * Auto-detect appropriate line endings for e-mails. * - * $conf['mail_line_endings'] will override this setting. + * The default mail line ending is "\n", however this conditional will set the + * line ending to the Windows required "\r\n". */ -define('MAIL_LINE_ENDINGS', isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE ? "\r\n" : "\n"); +if (isset($_SERVER['WINDIR']) || strpos($_SERVER['SERVER_SOFTWARE'], 'Win32') !== FALSE) { + config('system.mail') + ->set('line_endings', '\r\n') + ->save(); +} /** * Composes and optionally sends an e-mail message. @@ -214,12 +219,12 @@ function drupal_mail($module, $key, $to, $langcode, $params = array(), $from = N * * The selection of a particular implementation is controlled via the variable * 'system.mail.system', which is a keyed array. The default implementation - * is the class whose name is the value of 'default-system' key. A more specific - * match first to key and then to module will be used in preference to the - * default. To specificy a different class for all mail sent by one module, set - * the class name as the value for the key corresponding to the module name. To - * specificy a class for a particular message sent by one module, set the class - * name as the value for the array key that is the message id, which is + * is the class whose name is the value of 'default' key. A more specific match + * first to key and then to module will be used in preference to the default. To + * specificy a different class for all mail sent by one module, set the class + * name as the value for the key corresponding to the module name. To specificy + * a class for a particular message sent by one module, set the class name as + * the value for the array key that is the message id, which is * "${module}_${key}". * * For example to debug all mail sent by the user module by logging it to a @@ -227,7 +232,7 @@ function drupal_mail($module, $key, $to, $langcode, $params = array(), $from = N * * @code * array( - * 'default-system' => 'Drupal\Core\Mail\PhpMail', + * 'default' => 'Drupal\Core\Mail\PhpMail', * 'user' => 'DevelMailLog', * ); * @endcode @@ -237,7 +242,7 @@ function drupal_mail($module, $key, $to, $langcode, $params = array(), $from = N * * @code * array( - * 'default-system' => 'Drupal\Core\Mail\PhpMail', + * 'default' => 'Drupal\Core\Mail\PhpMail', * 'user' => 'DevelMailLog', * 'contact_page_autoreply' => 'DrupalDevNullMailSend', * ); @@ -273,7 +278,7 @@ function drupal_mail_system($module, $key) { $class = $configuration[$module]; } else { - $class = $configuration['default-system']; + $class = $configuration['default']; } if (empty($instances[$class])) { @@ -502,7 +507,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) { $chunk = $casing($chunk); } // Format it and apply the current indentation. - $output .= drupal_wrap_mail($chunk, implode('', $indent)) . MAIL_LINE_ENDINGS; + $output .= drupal_wrap_mail($chunk, implode('', $indent)) . config('system.mail')->get('line_endings'); // Remove non-quotation markers from indentation. $indent = array_map('_drupal_html_to_text_clean', $indent); } diff --git a/core/lib/Drupal/Core/Mail/PhpMail.php b/core/lib/Drupal/Core/Mail/PhpMail.php index 8dac73d..fbbedda 100644 --- a/core/lib/Drupal/Core/Mail/PhpMail.php +++ b/core/lib/Drupal/Core/Mail/PhpMail.php @@ -59,7 +59,7 @@ public function mail(array $message) { foreach ($message['headers'] as $name => $value) { $mimeheaders[] = $name . ': ' . mime_header_encode($value); } - $line_endings = config('system.mail')->get('line_endings') ?: MAIL_LINE_ENDINGS; + $line_endings = config('system.mail')->get('line_endings'); // Prepare mail commands. $mail_subject = mime_header_encode($message['subject']); // Note: e-mail uses CRLF for line-endings. PHP's API requires LF diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index cfd1bf0..39e5af1 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -751,7 +751,7 @@ protected function setUp() { $this->resetAll(); // Use the test mail class instead of the default mail handler class. - config('system.mail')->set('system', array('default-system' => 'Drupal\Core\Mail\VariableLog'))->save(); + config('system.mail')->set('system', array('default' => 'Drupal\Core\Mail\VariableLog'))->save(); drupal_set_time_limit($this->timeLimit); $this->setup = TRUE; diff --git a/core/modules/system/config/system.mail.yml b/core/modules/system/config/system.mail.yml index bdcced3..4672edc 100644 --- a/core/modules/system/config/system.mail.yml +++ b/core/modules/system/config/system.mail.yml @@ -1,2 +1,3 @@ system: - 'default-system': 'Drupal\Core\Mail\PhpMail' + 'default': 'Drupal\Core\Mail\PhpMail' +line_endings: '\n' diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php index 06e230d..77d6d38 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php @@ -349,7 +349,7 @@ public function testVeryLongLineWrap() { $input = 'Drupal

' . str_repeat('x', 2100) . '
Drupal'; $output = drupal_html_to_text($input); // This awkward construct comes from includes/mail.inc lines 8-13. - $eol = config('system.mail')->get('line_endings') ?: MAIL_LINE_ENDINGS; + $eol = config('system.mail')->get('line_endings'); // We must use strlen() rather than drupal_strlen() in order to count // octets rather than characters. $line_length_limit = 1000 - drupal_strlen($eol); diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php index 67423e1..a2229fa 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php @@ -42,7 +42,7 @@ function setUp() { parent::setUp(); // Set MailTestCase (i.e. this class) as the SMTP library - config('system.mail')->set('system', array('default-system' => 'Drupal\system\Tests\Mail\MailTest'))->save(); + config('system.mail')->set('system', array('default' => 'Drupal\system\Tests\Mail\MailTest'))->save(); } /**