From 7b8c666b72d717ac878dca887fc2198d39750bff Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 14 Sep 2019 21:34:51 +0000 Subject: [PATCH] Mail: Add a unit test to make sure `wp_mail()` does not duplicate the `MIME-Version` header added automatically by PHPMailer. See #43542. git-svn-id: https://develop.svn.wordpress.org/trunk@46118 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/mail.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/phpunit/tests/mail.php b/tests/phpunit/tests/mail.php index 951615136b..39c6036d2c 100644 --- a/tests/phpunit/tests/mail.php +++ b/tests/phpunit/tests/mail.php @@ -273,6 +273,22 @@ class Tests_Mail extends WP_UnitTestCase { $this->assertTrue( strpos( $mailer->get_sent()->header, $expected ) > 0 ); } + /** + * @ticket 43542 + */ + public function test_wp_mail_does_not_duplicate_mime_version_header() { + $to = 'user@example.com'; + $subject = 'Test email with a MIME-Version header'; + $message = 'The MIME-Version header should not be duplicated.'; + $headers = 'MIME-Version: 1.0'; + $expected = 'MIME-Version: 1.0'; + + wp_mail( $to, $subject, $message, $headers ); + + $mailer = tests_retrieve_phpmailer_instance(); + $this->assertEquals( 1, substr_count( $mailer->get_sent()->header, $expected ) ); + } + function wp_mail_quoted_printable( $mailer ) { $mailer->Encoding = 'quoted-printable'; }