[wp-trac] [WordPress Trac] #15448: wp_mail() sets Content-Type header twice for multipart emails
WordPress Trac
noreply at wordpress.org
Mon Sep 1 16:55:31 UTC 2025
#15448: wp_mail() sets Content-Type header twice for multipart emails
-------------------------------------------------+-------------------------
Reporter: rmccue | Owner: SirLouen
Type: defect (bug) | Status: accepted
Priority: high | Milestone: 6.9
Component: Mail | Version: 2.8
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests has-test- | Focuses:
info |
-------------------------------------------------+-------------------------
Comment (by sajjad67):
== Test Report
=== Description
This report validates whether the indicated patch works as expected.
Patch tested: https://github.com/WordPress/wordpress-
develop/pull/9500.patch
=== Environment
- WordPress: 6.9-alpha-60093-src
- PHP: 8.2.29
- Server: nginx/1.29.1
- Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
- Browser: Chrome 139.0.0.0
- OS: Windows 10/11
- Theme: Twenty Twenty-Five 1.3
- MU Plugins: None activated
- Plugins:
* Amazon S3 Email Testing 1.0.0
* Manual Multipart/Alternative/Mixed Test 1.0.0
* Test Reports 1.2.0
* WP Mail SMTP 4.6.0
=== Actual Results
1. ✅ Emails sent via wp_mail() with multipart content are now parsed
correctly.
2. ✅ Mailpit displays plain text and HTML parts in their respective
tabs.
3. ✅ Attachments (e.g., attachment.pdf) are properly recognized and
accessible.
4. ✅ MIME boundaries and headers are no longer visible in the email
body.
=== Additional Notes
Before applying the patch, Mailpit displayed the raw multipart structure
with MIME headers inline, and attachments were not detected.
After applying the patch, the behavior aligns with the expected PHPMailer
handling of multipart messages. Also, no regressions observed in basic
wp_mail() functionality.
=== Supplemental Artifacts
Raw email after the patch (Multipart/Alternative Email Test) -
[[Image(https://img001.prntscr.com/file/img001/eF41u4l8T1KvVXP6ym1JkA.png)]]
{{{
Return-Path: <sender at test.com>
Received: from localhost (wordpress-develop-php-1.wordpress-
develop_wpdevnet. [172.18.0.3])
by e28520ee0bd5 (Mailpit) with SMTP
for <test at test.com>; Mon, 1 Sep 2025 16:40:16 +0000 (UTC)
Date: Mon, 1 Sep 2025 16:40:16 +0000
To: test at test.com
From: WordPress Development <sender at test.com>
Subject: Multipart/Alternative Email Test
Message-ID: <a9gUEp7IlF521nXSVU5fYOL0JSXLUiYkIdc5zFlJYI at localhost>
X-Mailer: WPMailSMTP/Mailer/smtp 4.6.0
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="b1=_a9gUEp7IlF521nXSVU5fYOL0JSXLUiYkIdc5zFlJYI"
Content-Transfer-Encoding: 8bit
--b1=_a9gUEp7IlF521nXSVU5fYOL0JSXLUiYkIdc5zFlJYI
Content-Type: multipart/alternative; boundary="h2QJgSwi06UTDAMj2bci6QjM";
charset=us-ascii
--h2QJgSwi06UTDAMj2bci6QjM
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
This is the plain text version of the email.
--h2QJgSwi06UTDAMj2bci6QjM
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
<html><body><p>This is the <strong>HTML version</strong> of the
email.</p></body></html>
--h2QJgSwi06UTDAMj2bci6QjM--
--b1=_a9gUEp7IlF521nXSVU5fYOL0JSXLUiYkIdc5zFlJYI
Content-Type: application/octet-stream; name=attachment.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=attachment.pdf
....
RkY1RDc4QjhGMjg+IF0KPj4Kc3RhcnR4cmVmCjEyNzg3CiUlRU9GCg==
--b1=_a9gUEp7IlF521nXSVU5fYOL0JSXLUiYkIdc5zFlJYI--
}}}
Raw email after the patch (Multipart/Mixed Email Test) -
[[Image(https://img001.prntscr.com/file/img001/lt688EYwQAqOFLkm2yv7Dw.png)]]
[[Image(https://img001.prntscr.com/file/img001/0UvS1y6tRTq81A11cFGW8w.png)]]
{{{
Return-Path: <sender at test.com>
Received: from localhost (wordpress-develop-php-1.wordpress-
develop_wpdevnet. [172.18.0.3])
by e28520ee0bd5 (Mailpit) with SMTP
for <test at test.com>; Mon, 1 Sep 2025 16:41:13 +0000 (UTC)
Date: Mon, 1 Sep 2025 16:41:13 +0000
To: test at test.com
From: WordPress Development <sender at test.com>
Subject: Multipart/Mixed Email Test
Message-ID: <aZAPqJglmQhnxi5DU712pYM8Pma5aEpMslG2nl7Y at localhost>
X-Mailer: WPMailSMTP/Mailer/smtp 4.6.0
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="b1=_aZAPqJglmQhnxi5DU712pYM8Pma5aEpMslG2nl7Y"
Content-Transfer-Encoding: 8bit
--b1=_aZAPqJglmQhnxi5DU712pYM8Pma5aEpMslG2nl7Y
Content-Type: multipart/mixed; boundary="8z4V5qzeofKwtWjpe9HO05Vl";
charset=us-ascii
--8z4V5qzeofKwtWjpe9HO05Vl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
This is a multipart/mixed email with an attachment.
--8z4V5qzeofKwtWjpe9HO05Vl
Content-Type: text/plain; name="test-attachment.txt"
Content-Disposition: attachment; filename="test-attachment.txt"
Content-Transfer-Encoding: base64
VGhpcyBpcyB0aGUgY29udGVudCBvZiB0aGUgdGVzdCBhdHRhY2htZW50Lg==
--8z4V5qzeofKwtWjpe9HO05Vl--
--b1=_aZAPqJglmQhnxi5DU712pYM8Pma5aEpMslG2nl7Y
Content-Type: application/octet-stream; name=attachment.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=attachment.pdf
....
RkY1RDc4QjhGMjg+IF0KPj4Kc3RhcnR4cmVmCjEyNzg3CiUlRU9GCg==
--b1=_aZAPqJglmQhnxi5DU712pYM8Pma5aEpMslG2nl7Y--
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/15448#comment:92>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list