Skip to content

Commit 13431d6

Browse files
committed
Mail: Revert Set sender address by default.
This reverts [61010]. Setting the sender address by default has shown to reduce deliverability for emails for sites that were working correctly in 6.8 and before. As reduced deliverability can harm IP reputation which means it's not just the single WordPress install that is harmed, [61010] is being reverted out of an abundance of caution. Follow up to [61010]. Reviewed by audrasjb, wildworks. Merges [61537] to the 6.9 branch. Props jorbin, dmsnell, SirLouen, wildworks, desrosj, siliconforks, digitalblanket, studiomondiale, zoe20, Monarobase, amanandhishoe, Fixes #64368.See #49687. git-svn-id: https://develop.svn.wordpress.org/branches/6.9@61549 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f98e45b commit 13431d6

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/wp-includes/pluggable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
444444
$from_name = apply_filters( 'wp_mail_from_name', $from_name );
445445

446446
try {
447-
$phpmailer->setFrom( $from_email, $from_name );
447+
$phpmailer->setFrom( $from_email, $from_name, false );
448448
} catch ( PHPMailer\PHPMailer\Exception $e ) {
449449
$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
450450
$mail_error_data['phpmailer_exception_code'] = $e->getCode();

tests/phpunit/tests/pluggable/wpMail.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,18 +411,21 @@ public function test_wp_mail_addresses_arent_encoded() {
411411
}
412412

413413
/**
414-
* Test that the Sender field in the SMTP envelope is set by Core.
414+
* Test that the Sender field in the SMTP envelope is not set by Core.
415415
*
416-
* A missing Sender field can lead to messages failing DMARC SPF checks.
416+
* Correctly setting the Sender requires knowledge that is not available
417+
* to Core. An incorrect value will often lead to messages being rejected
418+
* by the receiving MTA, so it's the admin's responsibility to
419+
* set it correctly.
417420
*
418-
* @ticket 49687
421+
* @ticket 37736
419422
*/
420-
public function test_wp_mail_sender_set() {
421-
wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should have been set.' );
423+
public function test_wp_mail_sender_not_set() {
424+
wp_mail( 'user@example.org', 'Testing the Sender field', 'The Sender field should not have been set.' );
422425

423426
$mailer = tests_retrieve_phpmailer_instance();
424427

425-
$this->assertSame( 'wordpress@example.org', $mailer->Sender );
428+
$this->assertSame( '', $mailer->Sender );
426429
}
427430

428431
/**

0 commit comments

Comments
 (0)