From c50726aa818f3f96a81a0d006372950a35a252e0 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin <622599+aaronjorbin@users.noreply.github.com> Date: Fri, 23 Jan 2026 17:19:25 -0600 Subject: [PATCH] Revert [61010] --- src/wp-includes/pluggable.php | 2 +- tests/phpunit/tests/pluggable/wpMail.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 91b77c5e8d587..688f910dd7390 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -444,7 +444,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() $from_name = apply_filters( 'wp_mail_from_name', $from_name ); try { - $phpmailer->setFrom( $from_email, $from_name ); + $phpmailer->setFrom( $from_email, $from_name, false ); } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); $mail_error_data['phpmailer_exception_code'] = $e->getCode(); diff --git a/tests/phpunit/tests/pluggable/wpMail.php b/tests/phpunit/tests/pluggable/wpMail.php index 785c73eccda6e..96292cc5838a1 100644 --- a/tests/phpunit/tests/pluggable/wpMail.php +++ b/tests/phpunit/tests/pluggable/wpMail.php @@ -411,18 +411,21 @@ public function test_wp_mail_addresses_arent_encoded() { } /** - * Test that the Sender field in the SMTP envelope is set by Core. + * Test that the Sender field in the SMTP envelope is not set by Core. * - * A missing Sender field can lead to messages failing DMARC SPF checks. + * Correctly setting the Sender requires knowledge that is not available + * to Core. An incorrect value will often lead to messages being rejected + * by the receiving MTA, so it's the admin's responsibility to + * set it correctly. * - * @ticket 49687 + * @ticket 37736 */ - public function test_wp_mail_sender_set() { - wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should have been set.' ); + public function test_wp_mail_sender_not_set() { + wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should not have been set.' ); $mailer = tests_retrieve_phpmailer_instance(); - $this->assertSame( 'wordpress@example.org', $mailer->Sender ); + $this->assertSame( '', $mailer->Sender ); } /**