Mail: reset Encoding to 8-bit in wp_mail().

The PHPMailer library may automatically switch its encoding based on various internal factors.

This commit fixes a bug where the `$phpmailer` global was unintentionally persisting its `Encoding` property from the first `wp_mail()` call to all subsequent calls.

This includes unit tests to verify the fix is accurate, and a change to the mock-mailer helper that worked around this bug just-in-time when running the test suite.

Props codebuddy, dilip2615, rishabhwp, sajjad67, sirlouen, stephenharris.

Fixes #33972.
Built from https://develop.svn.wordpress.org/trunk@61131


git-svn-id: http://core.svn.wordpress.org/trunk@60467 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
johnjamesjacoby
2025-11-04 17:20:34 +00:00
parent 407748f330
commit 36fab9c398
2 changed files with 10 additions and 1 deletions

View File

@@ -384,6 +384,15 @@ if ( ! function_exists( 'wp_mail' ) ) :
$phpmailer->Body = '';
$phpmailer->AltBody = '';
/*
* Reset encoding to 8-bit, as it may have been automatically downgraded
* to 7-bit by PHPMailer (based on the body contents) in a previous call
* to wp_mail().
*
* See https://core.trac.wordpress.org/ticket/33972
*/
$phpmailer->Encoding = PHPMailer\PHPMailer\PHPMailer::ENCODING_8BIT;
// Set "From" name and email.
// If we don't have a name from the input headers.

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.9-beta3-61130';
$wp_version = '6.9-beta3-61131';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.