only in patch2: unchanged: --- a/modules/simpletest/tests/mail.test +++ b/modules/simpletest/tests/mail.test @@ -59,6 +59,38 @@ class MailTestCase extends DrupalWebTestCase implements MailSystemInterface { $this->assertNull(self::$sent_message, 'Message was canceled.'); } + /** + * Checks the From: and Reply-to: headers. + */ + function testFromHeader() { + global $language; + + // Reset the class variable holding a copy of the last sent message. + self::$sent_message = NULL; + + $from_email = 'simpletest@example.com'; + $reply_email = 'someone_else@sub.example.com'; + + // Use MailTestCase for sending a message. + 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 via Drupal\" <$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.'); + + // Reset the class variable holding a copy of the last sent message. + 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($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.'); + } + /** * Concatenate and wrap the e-mail body for plain-text mails. *