[wp-trac] [WordPress Trac] #56779: wp_mail header ignores multiple headers with same name
WordPress Trac
noreply at wordpress.org
Sat Jul 12 18:41:33 UTC 2025
#56779: wp_mail header ignores multiple headers with same name
-------------------------------------------------+-------------------------
Reporter: pentatonicfunk | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Mail | Version:
Severity: major | Resolution:
Keywords: needs-patch has-test-info good- | Focuses:
first-bug |
-------------------------------------------------+-------------------------
Changes (by SirLouen):
* keywords: => needs-patch has-test-info good-first-bug
* type: enhancement => defect (bug)
* severity: normal => major
Comment:
== Reproduction Report
=== Description
✅ This report validates whether the issue can be reproduced.
=== 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: Windows 10/11
- Theme: Twenty Twenty-Five 1.2
- MU Plugins: None activated
- Plugins:
* Micro Email Testing 1.0.0
* Test Reports 1.2.0
=== Steps
1. Instructions as explained in OP, using two headers with same key,
different value
2. 🐞 Only second value will prevail
=== Actual Results
- ✅ Error condition occurs (reproduced).
=== Additional Notes
- I can still see your point of why someone might need to add multiple
identical header tags (updating Mailgun
[https://documentation.mailgun.com/docs/mailgun/user-manual/sending-
messages/#passing-sending-options docs here])
- In fact, this is not an enhancement, but a regression that was
introduced in [5639]. Historically, headers added to `AddCustomHeader` in
the `default` case. But in this commit, headers were firstly trimmed to
their keys.
Problem is that the fix will be a little less direct as it should because
[https://github.com/SirLouen/wordpress-
develop/blob/8938a326244e3fb1e27e0f64413f72fffe8467b1/src/wp-
includes/pluggable.php#L357 some lines after] there is a
`$phpmailer->clearCustomHeaders`
So the solution as suggested could go, to iterate adding another array
with id => value to the current created `default` array, and then
[https://github.com/SirLouen/wordpress-
develop/blob/8938a326244e3fb1e27e0f64413f72fffe8467b1/src/wp-
includes/pluggable.php#L506 releasing those headers] with an extra
iterator.
Having this in mind, it doesn't look too difficult, so I will add `good-
first-bug` in case someone wants to take this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/56779#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list