[wp-trac] [WordPress Trac] #36219: wp_mail_failed action returns an WP_Error object

WordPress Trac noreply at wordpress.org
Sat Mar 12 14:17:36 UTC 2016


#36219: wp_mail_failed action returns an WP_Error object
--------------------------+-----------------------------
 Reporter:  paulcgt       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Mail          |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 In pluggable.php's wp_mail() function, directly after wp_mail() calls
 PHPMailer's send() operation, it catches a phpmailerException exception
 and uses that to create a WP_Error object that get's passed to the
 do_action() method.

 WP_Error's constructor requires the code parameter not to be empty. If it
 is empty, WP_Error does not construct the WP_Error object.

 The phpmailerException returned from the send() operation does not contain
 an error code when an invalid From address was specified (probably other
 several other conditions also), which results in the following line of
 code returning an empty WP_Error object:

 do_action( 'wp_mail_failed', new WP_Error( $e->getCode(),
 $e->getMessage(), $mail_error_data ) );

 This could be fixed by first testing if $e->getCode() is empty and if it
 is, then rather to default a code such as "wp_mail_phpmailer_error", or
 similar.

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


More information about the wp-trac mailing list