[wp-trac] [WordPress Trac] #15448: wp_mail() sets Content-Type header twice for multipart emails
WordPress Trac
noreply at wordpress.org
Mon Jul 14 15:13:41 UTC 2025
#15448: wp_mail() sets Content-Type header twice for multipart emails
-------------------------------------------------+-------------------------
Reporter: rmccue | Owner:
| SergeyBiryukov
Type: feature request | Status: reviewing
Priority: normal | Milestone: Future
| Release
Component: Mail | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has-test- | Focuses:
info reported-upstream |
-------------------------------------------------+-------------------------
Comment (by tusharbharti):
== Test Report
=== Description
This report validates whether the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/9063
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- Server: nginx/1.29.0
- Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.29)
- Browser: Chrome 138.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
* Manual Multipart Email Debug 1.1
* Test Reports 1.2.0
=== Actual Results
1. ✅ Patch is working properly and we can send multipart data via
`$body` array
=== Supplemental Artifacts
==== Code
A sample plugin to test the new patch
{{{
<?php
/*
Plugin Name: Manual Multipart Email Debug (Array Body)
Description: Debug plugin to send multipart email using array body. Adds
button in Tools page.
Version: 1.2
*/
add_action('admin_menu', function() {
add_management_page(
'Manual Multipart Email',
'Manual Multipart Email',
'manage_options',
'manual-multipart-email',
'manual_multipart_email_page'
);
});
function manual_multipart_email_page() {
if (!current_user_can('manage_options')) {
return;
}
if (isset($_POST['manual_multipart_send_email'])) {
$to = get_option('admin_email');
$subject = 'Reproduce Original Issue (Array Body Method)';
$body = array(
'text/plain' => 'Hello world! This is plain text from array
body.',
'text/html' => '<html><body><p>Hello world! This is
<strong>HTML</strong> from array body.</p></body></html>',
);
$headers = array(
'From: Manual Multipart <manual at example.com>',
);
$sent = wp_mail($to, $subject, $body, $headers);
if ($sent) {
echo '<div class="notice notice-success"><p>Email sent
successfully to admin email (' . esc_html($to) . ').</p></div>';
} else {
echo '<div class="notice notice-error"><p>Error sending array
body email.</p></div>';
}
}
?>
<div class="wrap">
<h1>Manual Multipart Email Debug (Array Body)</h1>
<form method="post">
<?php submit_button('Send Test Email', 'primary',
'manual_multipart_send_email'); ?>
</form>
</div>
<?php
}
}}}
==== Results
[[Image(https://i.ibb.co/PZKYRJ37/image.png)]]
[[Image(https://i.ibb.co/7Npk6zvQ/image.png)]]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/15448#comment:83>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list