[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:11:05 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 lakshyajeet):
== Test Report
=== Description
This report validates whether the patch correctly addresses the
`wp_mail()` multipart email functionality by introducing the a array-based
`$message` parameter for native multipart sending.
Patch tested: https://github.com/WordPress/wordpress-
develop/pull/9063.patch
=== 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 137.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
* Test Reports 1.2.0
=== Actual Results
1. ✅ The report confirms the patch works correctly.
=== Additional Notes
- Snippets used for testing
- Manually sending a multipart mail.
{{{#!php
<?php
$subject = 'Reproduce Original Issue (Manual Multipart Header)';
$body = '--TestBoundary_Manual
Content-Type: text/plain; charset=UTF-8
Hello world! This is plain text from manual multipart.
--TestBoundary_Manual
Content-Type: text/html; charset=UTF-8
<html><body><p>Hello world! This is <strong>HTML</strong> from manual
multipart.</p></body></html>
--TestBoundary_Manual--';
$headers = array(
'MIME-Version: 1.0',
'From: Manual Multipart <manual at example.com>',
'Content-Type: multipart/alternative; boundary="TestBoundary_Manual"'
);
$sent = wp_mail($to, $subject, $body, $headers);
if (!$sent) {
$error = 'Error reproducing original issue email';
}
}}}
- Received Mail
{{{
Content-Type: multipart/alternative; charset=
Date: Mon, 14 Jul 2025 14:49:29 +0000
From: Manual Multipart <manual at example.com>
MIME-Version: 1.0
Message-ID: <oNS5dFXICClL5kOA6XelQAaXByjYDMKXtJHJRkoyKBk at localhost>
Received: from localhost by mailhog.example (MailHog)
id YhfTbmw69cKDkxtZsPkpYTt7UfGrH5159XlngKPLU7g=@mailhog.example;
Mon, 14 Jul 2025 14:49:29 +0000
Return-Path: <manual at example.com>
Subject: Reproduce Original Issue (Manual Multipart Header)
To: test at example.com
X-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)
--TestBoundary_Manual
Content-Type: text/plain; charset=UTF-8
Hello world! This is plain text from manual multipart.
--TestBoundary_Manual
Content-Type: text/html; charset=UTF-8
<html><body><p>Hello world! This is <strong>HTML</strong> from manual
multipart.</p></body></html>
--TestBoundary_Manual--
}}}
- Using the new feature `$message` as an array.
{{{#!php
<?php
$subject = 'Test Patch';
$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: Patch Tester <patch at example.com>',
);
$sent = wp_mail($to, $subject, $body, $headers);
if (!$sent) {
$error = 'Error sending patch-tested array email';
}
}}}
- Received mail
{{{
Content-Transfer-Encoding: 8bit
Content-Type: multipart/alternative;
boundary="b1=_2Y7MTiqKWSHhSj2x8qM1RMRWPivHf8MKoMNdrHYeKDE"
Date: Mon, 14 Jul 2025 14:49:27 +0000
From: Patch Tester <patch at example.com>
MIME-Version: 1.0
Message-ID: <2Y7MTiqKWSHhSj2x8qM1RMRWPivHf8MKoMNdrHYeKDE at localhost>
Received: from localhost by mailhog.example (MailHog)
id knwaRMzFmUCibRtxpzIqTYYq2XnfkSQ2C6GG7LRBat8=@mailhog.example;
Mon, 14 Jul 2025 14:49:27 +0000
Return-Path: <patch at example.com>
Subject: Test Patch
To: test at example.com
X-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)
--b1=_2Y7MTiqKWSHhSj2x8qM1RMRWPivHf8MKoMNdrHYeKDE
Content-Type: text/plain; charset=us-ascii
Hello world! This is plain text from array body.
--b1=_2Y7MTiqKWSHhSj2x8qM1RMRWPivHf8MKoMNdrHYeKDE
Content-Type: text/html; charset=us-ascii
<html><body><p>Hello world! This is <strong>HTML</strong> from array
body.</p></body></html>
--b1=_2Y7MTiqKWSHhSj2x8qM1RMRWPivHf8MKoMNdrHYeKDE--
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/15448#comment:81>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list