[wp-trac] [WordPress Trac] #62940: wp_mail(): Address header parsing is not RFC-5322 complient and fails on quoted-string when including a "<", ">" or ", "

WordPress Trac noreply at wordpress.org
Thu Aug 21 12:01:22 UTC 2025


#62940: wp_mail(): Address header parsing is not RFC-5322 complient and fails on
quoted-string when including a "<", ">" or ","
-------------------------------------------------+-------------------------
 Reporter:  bhujagendra                          |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Mail                                 |     Version:  2.1.1
 Severity:  normal                               |  Resolution:
 Keywords:  needs-patch needs-unit-tests has-    |     Focuses:
  test-info                                      |
-------------------------------------------------+-------------------------

Comment (by jdeep):

 @SirLouen @bhujagendra,

 Yesterday, I took some time to read RFC 5322 and 2822. WordPress Core
 supporting fully RFC-5322 compliant email headers does seem like a very
 ambitious feature. However, I feel this is much suited to be implemented
 properly (without IMAP extension) in [https://github.com/WordPress
 /wordpress-develop/blob/d71f29ff0899c6eb29bc037a7c521a966405cb35/src/wp-
 includes/PHPMailer/PHPMailer.php#L1257 PHPMailer::parseAddresses()] itself
 rather than in WordPress. Naively splitting on `,` isn't the best way to
 handle headers with multiple addresses.

 Instead of trying to implement a new parser inside WordPress, I think it
 is better to make the PHP fallback in PHPMailer more RFC 5322–aware.

 But that also means it will not be fixed soon and will probably takes a
 few months to years to get the latest PHPMailer implementation in
 WordPress.

 In the meantime, I’ll try putting together a WordPress patch that handles
 at least the quoted-comma case. This is meant to be a temporary fix till
 the time we get a better implementation in PHPMailer itself.

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


More information about the wp-trac mailing list