Mail: Improve multipart message handling in wp_mail().
This improves how `wp_mail()` handles `Content-Type` headers for multipart messages, preventing cases where the header could be duplicated. Developed in https://github.com/WordPress/wordpress-develop/pull/9500 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 #15448. Built from https://develop.svn.wordpress.org/trunk@61201 git-svn-id: http://core.svn.wordpress.org/trunk@60537 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -174,6 +174,7 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
* @since 5.5.0 is_email() is used for email validation,
|
||||
* instead of PHPMailer's default validator.
|
||||
* @since 6.9.0 Added $embeds parameter.
|
||||
* @since 6.9.0 Improved Content-Type header handling for multipart messages.
|
||||
*
|
||||
* @global PHPMailer\PHPMailer\PHPMailer $phpmailer
|
||||
*
|
||||
@@ -351,6 +352,9 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
} elseif ( false !== stripos( $charset_content, 'boundary=' ) ) {
|
||||
$boundary = trim( str_replace( array( 'BOUNDARY=', 'boundary=', '"' ), '', $charset_content ) );
|
||||
$charset = '';
|
||||
if ( preg_match( '~^multipart/(\S+)~', $content_type, $matches ) ) {
|
||||
$content_type = 'multipart/' . strtolower( $matches[1] ) . '; boundary="' . $boundary . '"';
|
||||
}
|
||||
}
|
||||
|
||||
// Avoid setting an empty $content_type.
|
||||
@@ -547,10 +551,6 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( false !== stripos( $content_type, 'multipart' ) && ! empty( $boundary ) ) {
|
||||
$phpmailer->addCustomHeader( sprintf( 'Content-Type: %s; boundary="%s"', $content_type, $boundary ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $attachments ) ) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.9-beta4-61200';
|
||||
$wp_version = '6.9-beta4-61201';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user