[wp-trac] [WordPress Trac] #33972: static use of PHPMailer class results in stale state between calls to wp_mail()

WordPress Trac noreply at wordpress.org
Wed Aug 20 19:46:44 UTC 2025


#33972: static use of PHPMailer class results in stale state between calls to
wp_mail()
-------------------------------------------------+-------------------------
 Reporter:  codebuddy                            |       Owner:  rishabhwp
     Type:  defect (bug)                         |      Status:  assigned
 Priority:  normal                               |   Milestone:
Component:  Mail                                 |     Version:  4.3
 Severity:  critical                             |  Resolution:
 Keywords:  has-test-info good-first-bug has-    |     Focuses:
  patch                                          |
-------------------------------------------------+-------------------------
Changes (by rishabhwp):

 * keywords:  has-test-info good-first-bug has-patch changes-requested =>
     has-test-info good-first-bug has-patch


Comment:

 Hi @SirLouen,

 I've updated the PR per your feedback in comment #16:

 1. Removed the line in `mock-mailer.php` that was forcing `$this->Encoding
 = '8bit'`
 2. Changed `wp_mail()` to clear the encoding property
 (`$phpmailer->Encoding = ''`) instead of defaulting to 8bit
 3. Updated the unit test to expect empty encoding for short messages,
 matching PHPMailer's natural behavior

 The test now passes. Thanks for the detailed guidance!

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


More information about the wp-trac mailing list