[wp-trac] [WordPress Trac] #43425: WP_Mail BCC and CC - RCPT TO Errors

WordPress Trac noreply at wordpress.org
Thu Jul 10 09:45:45 UTC 2025


#43425: WP_Mail BCC and CC - RCPT TO Errors
--------------------------+------------------------------
 Reporter:  JWGarber1725  |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Mail          |     Version:  4.9.4
 Severity:  normal        |  Resolution:  worksforme
 Keywords:                |     Focuses:
--------------------------+------------------------------
Changes (by SirLouen):

 * status:  new => closed
 * resolution:   => worksforme


Comment:

 == Reproduction Report
 === Description
 ❌ This report can't validate that the issue can be reproduced.

 === Environment
 - WordPress: 6.9-alpha-60093-src
 - PHP: 8.2.28
 - Server: nginx/1.29.0
 - Database: mysqli (Server: 8.4.5 / Client: mysqlnd 8.2.28)
 - 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
   * Testing Emails 1.0.0
   * Test Reports 1.2.0

 === Testing instructions
 1. Used the code provided by OP for email testing.

 === Actual Results
 1. ❌ Error condition is not occurring any more

 === Additional Notes
 - First, you must consider, that WordPress use PHPMailer, not mail
 function directly. Although the function looks very similar, ideally you
 should respect the PHPMailer principles

 For the first code, I tried, and I received the CC in the source

 {{{
 Cc: myotheremail at myname.com
 Content-Type: text/plain; charset=UTF-8
 Date: Thu, 10 Jul 2025 07:56:31 +0000
 From: Test <wordpress at mailhog.local>
 MIME-Version: 1.0
 Message-ID:
 <d2jCdMLdqbdAmfggEcNWXMVc9fMIdkFn72uaaWTE4 at localhost.localdomain>
 Received: from localhost.localdomain by mailhog.example (MailHog)
           id 0i0vUZJ4L-HDW2m_7Kiv_U2FitXfsO6tnkrFMtqP6XI=@mailhog.example;
 Thu, 10 Jul 2025 07:56:31 +0000
 Return-Path: <wordpress at mailhog.local>
 Subject: TEST SUBJECT
 To: myemail at gmail.com
 X-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)

 Test
 }}}

 For the BCC part is a little more tricky because I'm using Mailhog for
 testing, which doesn't have support for handling clearly  BCC deliveries
 other than the logs. I've tried not only adding BCC but CC also:

 {{{
 $headers = 'From: Test <help at myname.com>' . "\r\n" . 'cc:
 myotheremail at myname.com' . "\r\n" . 'bcc: myotherotheremail at myname.com';
 $to = "myemail at gmail.com";
 $subject = "TEST BCC PART 2";
 $body = "Test";
 }}}

 This are the logs:

 {{{
 "Raw": {
     "From": "wordpress at mailhog.local",
     "To": [
       "myemail at gmail.com",
       "myotheremail at myname.com",
       "myotherotheremail at myname.com"
     ],
     "Data": "Date: Thu, 10 Jul 2025 09:38:26 +0000\r\nTo:
 myemail at gmail.com\r\nFrom: Test \u003cwordpress at mailhog.local\u003e\r\nCc:
 myotheremail at myname.com\r\nSubject: TEST BCC PART 2\r\nMessage-ID:
 \u003cESYCWyPLK2jSL3xWLCoFkuFVFTYnXrm0XKT4RAjw at localhost.localdomain\u003e\r
 \nX-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)\r
 \nMIME-Version: 1.0\r\nContent-Type: text/plain;
 charset=UTF-8\r\n\r\nTest\r\n",
     "Helo": "localhost.localdomain"
   }
 }}}

 So I don't see any problems with neither BCC or CC. Maybe there was a
 problem with your email delivery service OR it has been solved in certain
 PHPMailer vs over the years (given that this was reported 7 years ago).

 Anyway, personally I recommend to configure the headers in a string array,
 like this:

 {{{
 $headers = array(
         'From: Test <help at myname.com>',
         'Bcc: myotheremail at myname.com',
 );
 }}}

 Both methods work, for PHPMailer, this is slightly more robust.

 Also if you are confident that there is a problem with `wp_mail` you can
 hook directly to `PHPMailer` completely bypassing `wp_mail`
 [https://github.com/PHPMailer/PHPMailer/wiki/Using-PHPMailer-in-WordPress
 with this hook]. Then you can use `PHPMailer` class methods like `addCC`
 and `addBCC`

 Closing this ticket as `worksforme`

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


More information about the wp-trac mailing list