WP-r61201: Mail: Improve multipart message handling in wp_mail()#2193
Merged
WP-r61201: Mail: Improve multipart message handling in wp_mail()#2193
wp_mail()#2193Conversation
This improves how `wp_mail()` handles `Content-Type` headers for multipart messages, preventing cases where the header could be duplicated. Developed in WordPress/wordpress-develop#9500 WP:Props SirLouen, gitlost, rmccue, westi, MattyRob, bgermann, nacin, SergeyBiryukov, dd32, MikeHansenMe, Kleor, kitchin, JeffMatson, abcd95, westonruter, christinecooper, JohnVieth, dawidadach, imokweb, ayeshrajans, lakshyajeet, tusharbharti, sajjad67. Fixes https://core.trac.wordpress.org/ticket/15448. --- Merges https://core.trac.wordpress.org/changeset/61201 / WordPress/wordpress-develop@024bbfcc4c to ClassicPress.
Changed the type hint from WP_PHPMailer to MockPHPMailer in the $set_alt_body callback within the wpMail test. This ensures the callback matches the actual mock object used in the test environment.
xxsimoxx
approved these changes
Nov 13, 2025
Member
xxsimoxx
left a comment
There was a problem hiding this comment.
Before:
Content-Type: =?us-ascii?Q?multipart/alternative;_boundary=3D"----=3D=5FPa?=
=?us-ascii?Q?rt=5F18243133=5F1346573420.1408991447668"?=
MIME-Version: 1.0
Content-Type: multipart/alternative; charset=
After:
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="----=_Part_18243133_1346573420.1408991447668"; charset=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This improves how
wp_mail()handlesContent-Typeheaders for multipart messages, preventing cases where the header could be duplicated.Motivation and context
Backport and fixes potential header duplication.
How has this been tested?
Unit test included and fixed for ClassicPress.
Screenshots
N/A
Types of changes