diff --git a/core/includes/mail.inc b/core/includes/mail.inc index cb14e53..61dfb7e 100644 --- a/core/includes/mail.inc +++ b/core/includes/mail.inc @@ -143,7 +143,7 @@ function drupal_mail($module, $key, $to, $langcode, $params = array(), $reply = // To prevent e-mail from looking like spam, the addresses in the Sender and // Return-Path headers should have a domain authorized to use the // originating SMTP server. - $headers['Sender'] = $headers['Return-Path'] = $headers['Errors-To'] = $site_mail; + $headers['Sender'] = $headers['Return-Path'] = $site_mail; $headers['From'] = $site_config->get('name') . ' <' . $site_mail . '>'; if ($reply) { $headers['Reply-to'] = $reply; 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 c0879aa..927b7b1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/MailTest.php @@ -86,16 +86,21 @@ public function testFromAndReplyToHeader() { // Reset the class variable holding a copy of the last sent message. self::$sent_message = NULL; // Send an e-mail with a reply-to address specified. + $from_email = 'Drupal '; $reply_email = 'someone_else@example.com'; drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language, array(), $reply_email); // Test that the reply-to e-mail is just the e-mail and not the site name and // default sender e-mail. - $this->assertEqual($reply_email, self::$sent_message['headers']['Reply-to']); + $this->assertEqual($from_email, self::$sent_message['headers']['From'], 'Message is sent from the site email account.'); + $this->assertEqual($reply_email, self::$sent_message['headers']['Reply-to'], 'Message reply-to headers are set.'); + $this->assertFalse(isset(self::$sent_message['headers']['Errors-To']), 'Errors-to header must not be set, it is deprecated.'); self::$sent_message = NULL; // Send an e-mail and check that the From-header contains the site name. drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language); - $this->assertEqual('Drupal ', self::$sent_message['headers']['From']); + $this->assertEqual($from_email, self::$sent_message['headers']['From'], 'Message is sent from the site email account.'); + $this->assertFalse(isset(self::$sent_message['headers']['Reply-to']), 'Message reply-to is not set if not specified.'); + $this->assertFalse(isset(self::$sent_message['headers']['Errors-To']), 'Errors-to header must not be set, it is deprecated.'); } /**