[wp-trac] [WordPress Trac] #64940: PHP mailer Exception Handler

WordPress Trac noreply at wordpress.org
Tue Mar 24 14:15:36 UTC 2026


#64940: PHP mailer Exception Handler
-------------------------------------------+-----------------------------
 Reporter:  kajori                         |      Owner:  (none)
     Type:  enhancement                    |     Status:  new
 Priority:  normal                         |  Milestone:  Awaiting Review
Component:  Mail                           |    Version:  trunk
 Severity:  normal                         |   Keywords:
  Focuses:  performance, coding-standards  |
-------------------------------------------+-----------------------------
 Wrap the phpmailer_init hook (do_action_ref_array( 'phpmailer_init',
 array( &$phpmailer ) )) within a try-catch block in pluggable.php to
 ensure that exceptions during mail initialization are properly caught and
 logged.

 Currently, if an exception occurs during the execution of the
 phpmailer_init hook (e.g., due to file permission issues when accessing
 attachments or embedded resources), the failure is not clearly logged,
 making debugging difficult. In a real-world scenario, a failure occurred
 due to restricted access to an uploads directory, but the root cause was
 not visible until the hook was wrapped in an exception block.

 By handling exceptions at this point, errors such as "wp_mail failed" or
 file access issues (e.g., inability to access /wp-content/uploads) can be
 properly surfaced and logged, improving debuggability and reliability of
 the mail system.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64940>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list