From 8683799e93386211da02f8581ac6aaee843b0950 Mon Sep 17 00:00:00 2001 From: SirLouen Date: Mon, 8 Dec 2025 23:35:43 +0100 Subject: [PATCH 1/5] Mail: Temporary Failover Fix to Avoid Sender Issues --- src/wp-includes/pluggable.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 1d5ee194c9f10..2b8a5bc1bf379 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -444,7 +444,13 @@ 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 ); + // This block should be removed once PHPMailer supports setting the envelope sender separately. + $sendmail_path = ini_get( 'sendmail_path' ); + if ( str_contains( $sendmail_path, '-f' ) ) { + $phpmailer->setFrom( $from_email, $from_name, false ); + } else { + $phpmailer->setFrom( $from_email, $from_name ); + } } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); $mail_error_data['phpmailer_exception_code'] = $e->getCode(); From f132c57bf2e7d32680039dfa1afa9703868ed154 Mon Sep 17 00:00:00 2001 From: SirLouen Date: Tue, 9 Dec 2025 01:35:49 +0100 Subject: [PATCH 2/5] fix: Simplify envelope sender handling conditional plus better spotting for -f --- src/wp-includes/pluggable.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 2b8a5bc1bf379..ad6eb9f37f584 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -445,12 +445,8 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() try { // This block should be removed once PHPMailer supports setting the envelope sender separately. - $sendmail_path = ini_get( 'sendmail_path' ); - if ( str_contains( $sendmail_path, '-f' ) ) { - $phpmailer->setFrom( $from_email, $from_name, false ); - } else { - $phpmailer->setFrom( $from_email, $from_name ); - } + $auto = ! str_contains( $sendmail_path, ' -f' ); + $phpmailer->setFrom( $from_email, $from_name, $auto ); } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); $mail_error_data['phpmailer_exception_code'] = $e->getCode(); From f26fe72c1e5a1a74f66c39b60300bc9337bebe8f Mon Sep 17 00:00:00 2001 From: SirLouen Date: Tue, 9 Dec 2025 01:43:25 +0100 Subject: [PATCH 3/5] docs: Add reference comment --- src/wp-includes/pluggable.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index ad6eb9f37f584..c64170059024e 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -445,6 +445,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() try { // This block should be removed once PHPMailer supports setting the envelope sender separately. + // @see https://core.trac.wordpress.org/ticket/64368. $auto = ! str_contains( $sendmail_path, ' -f' ); $phpmailer->setFrom( $from_email, $from_name, $auto ); } catch ( PHPMailer\PHPMailer\Exception $e ) { From d8b1eb65a26e167137315460bc7cbe0ff0dff690 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 8 Dec 2025 17:10:53 -0800 Subject: [PATCH 4/5] Fix undefined variable introduced in f132c57 --- src/wp-includes/pluggable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index c64170059024e..84389d616085f 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -446,7 +446,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() try { // This block should be removed once PHPMailer supports setting the envelope sender separately. // @see https://core.trac.wordpress.org/ticket/64368. - $auto = ! str_contains( $sendmail_path, ' -f' ); + $auto = ! str_contains( ini_get( 'sendmail_path' ), ' -f' ); $phpmailer->setFrom( $from_email, $from_name, $auto ); } catch ( PHPMailer\PHPMailer\Exception $e ) { $mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' ); From 86ce34839d9bef86041287f64a4ce111aece1f90 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 8 Dec 2025 17:18:27 -0800 Subject: [PATCH 5/5] Improve comment for auto arg --- src/wp-includes/pluggable.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 84389d616085f..d1a18fd40e1ba 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -444,8 +444,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() $from_name = apply_filters( 'wp_mail_from_name', $from_name ); try { - // This block should be removed once PHPMailer supports setting the envelope sender separately. - // @see https://core.trac.wordpress.org/ticket/64368. + // Passing $auto can be removed once PHPMailer supports setting the envelope sender separately. See . $auto = ! str_contains( ini_get( 'sendmail_path' ), ' -f' ); $phpmailer->setFrom( $from_email, $from_name, $auto ); } catch ( PHPMailer\PHPMailer\Exception $e ) {