diff --git a/core/includes/mail.inc b/core/includes/mail.inc
index f390a65..b6991d0 100644
--- a/core/includes/mail.inc
+++ b/core/includes/mail.inc
@@ -7,8 +7,6 @@
/**
* 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");
@@ -213,13 +211,13 @@ function drupal_mail($module, $key, $to, $langcode, $params = array(), $from = N
* Drupal\Core\Mail\PhpMail implementation.
*
* The selection of a particular implementation is controlled via the variable
- * '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
+ * 'system.mail.system', which is a keyed array. The default implementation
+ * 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 +225,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 +235,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',
* );
@@ -262,7 +260,7 @@ function drupal_mail_system($module, $key) {
$id = $module . '_' . $key;
- $configuration = variable_get('mail_system', array('default-system' => 'Drupal\Core\Mail\PhpMail'));
+ $configuration = config('system.mail')->get('system');
// Look for overrides for the default class, starting from the most specific
// id, and falling back to the module name.
@@ -273,7 +271,7 @@ function drupal_mail_system($module, $key) {
$class = $configuration[$module];
}
else {
- $class = $configuration['default-system'];
+ $class = $configuration['default'];
}
if (empty($instances[$class])) {
diff --git a/core/lib/Drupal/Core/Mail/PhpMail.php b/core/lib/Drupal/Core/Mail/PhpMail.php
index f5ec995..a015a5b 100644
--- a/core/lib/Drupal/Core/Mail/PhpMail.php
+++ b/core/lib/Drupal/Core/Mail/PhpMail.php
@@ -59,13 +59,12 @@ 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);
+ $line_endings = MAIL_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
// on Unix and CRLF on Windows. Drupal automatically guesses the
- // line-ending format appropriate for your system. If you need to
- // override this, adjust $conf['mail_line_endings'] in settings.php.
+ // line-ending format appropriate for your system.
$mail_body = 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.
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 001e521..a30757f 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -764,7 +764,7 @@ protected function setUp() {
$this->resetAll();
// Use the test mail class instead of the default mail handler class.
- variable_set('mail_system', array('default-system' => 'Drupal\Core\Mail\VariableLog'));
+ config('system.mail')->set('system', array('default' => 'Drupal\Core\Mail\VariableLog'))->save();
drupal_set_time_limit($this->timeLimit);
// Temporary fix so that when running from run-tests.sh we don't get an
diff --git a/core/modules/system/config/system.mail.yml b/core/modules/system/config/system.mail.yml
new file mode 100644
index 0000000..47316e1
--- /dev/null
+++ b/core/modules/system/config/system.mail.yml
@@ -0,0 +1,2 @@
+system:
+ default: 'Drupal\Core\Mail\PhpMail'
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 5302c8d..43bd5c6 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 = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
+ $eol = MAIL_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 92be196..b8616ab 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
- variable_set('mail_system', array('default-system' => 'Drupal\system\Tests\Mail\MailTest'));
+ config('system.mail')->set('system.default', 'Drupal\system\Tests\Mail\MailTest')->save();
}
/**
@@ -98,4 +98,3 @@ public function mail(array $message) {
self::$sent_message = $message;
}
}
-
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 5fb624a..5a87b4c 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -2305,6 +2305,18 @@ function system_update_8039() {
}
/**
+ * Converts mail settings to config.
+ *
+ * @ingroup config_upgrade
+ */
+function system_update_8040() {
+ update_variables_to_config('system.mail', array(
+ 'mail_system' => 'system',
+ ));
+ update_variable_del('mail_line_endings');
+}
+
+/**
* @} End of "defgroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/