[wp-trac] [WordPress Trac] #30128: Allow to use associative arrays beside indexed arrays in wp_mail $headers

WordPress Trac noreply at wordpress.org
Fri Sep 26 08:22:52 UTC 2025


#30128: Allow to use associative arrays beside indexed arrays in wp_mail $headers
-------------------------------------------------+-------------------------
 Reporter:  marsjaninzmarsa                      |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Future
                                                 |  Release
Component:  Mail                                 |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests has-test-   |     Focuses:
  info                                           |
-------------------------------------------------+-------------------------
Changes (by nikunj8866):

 * keywords:  has-patch has-unit-tests has-test-info needs-testing => has-
     patch has-unit-tests has-test-info


Comment:

 == Test Report
 === Description
 ✅ This report validates that the indicated patch works as expected.

 Patch tested: https://github.com/WordPress/wordpress-develop/pull/9971

 === Environment
 - WordPress: 6.8.2
 - PHP: 8.4.10
 - Server: nginx/1.26.1
 - Database: mysqli (Server: 8.0.35 / Client: mysqlnd 8.4.10)
 - Browser: Chrome 140.0.0.0
 - OS: Windows 10/11
 - Theme: ModernPress 1.0.0
 - MU Plugins:
   * Email Testing 30128 1.0.0
 - Plugins:
   * Test Reports 1.2.0

 === Steps to Test
 1. Create a site in [https://localwp.com/ LocalWP].
 2. Add the [https://github.com/nikunj8866/email-testing-30128 Email
 Testing 30128] plugin into the `wp-content/mu-plugins` folder, which
 contains `wp_mail()` with associative array headers.
 3. Open the browser and run `YOURSITE.local/?send_test_email=1`. Replace
 YOURSITE with the actual LocalWP site name.
 4. 🐞 Before patch: You may see a fatal error because wp_mail() did not
 support associative array headers (https://prnt.sc/021DKTty7V6a).
 5. For viewing email logs within LocalWP, click, `Tools > Mailpit > Open
 Mailpit` button (https://prnt.sc/-pgSGe_z-0ub).

 === Actual Results
 1. ✅ Issue resolved with patch.
 2. Email sent successfully without errors, with all headers and data
 correctly applied.
 **Example email headers from Mailpit:**
 {{{
 Return-Path: <me at example.net>
 Received: from DESKTOP-23CTATP (kubernetes.docker.internal. [127.0.0.1])
         by DESKTOP-23CTATP (Mailpit) with SMTP
         for <test at example.com>; Fri, 26 Sep 2025 13:15:02 +0530 (IST)
 Subject: Test Subject
 To: test at example.com
 X-PHP-Originating-Script: 0:PHPMailer.php
 Date: Fri, 26 Sep 2025 07:45:02 +0000
 From: Me Myself <me at example.net>
 Cc: John Q Codex <jqc at wordpress.org>, iluvwp at wordpress.org
 Message-ID: <3FKnT6ayHPNRsacz6GgfJiYsKSSD3SiEu4NXED7d4 at wpgetapi.local>
 X-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8

 Testing multiple headers
 }}}

 === Additional Notes
 - Tested single-line notation for multiple CC/BCC addresses:
 {{{
 $headers = [
         'From: Me Myself <me at example.net>',
         'Cc: Fo McFoo <foo at example.com>, bar at example.com',
 ];
 }}}

 - ✅ Email sent successfully with this format as well.
 - ✅ Verified default WordPress email functionality (e.g., password reset
 link) sent successfully without issues.

 === Supplemental Artifacts
 Associative array headers: https://prnt.sc/SS32Bczx-Qhr
 Single-line notation headers: https://prnt.sc/SL4h2-1N95xD

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/30128#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list