Automattic\WooCommerce\Internal\Email
EmailLogger::capture_mail_error
Capture the PHPMailer error from a failed wp_mail() call so it can be included in the log entry.
Error attribution is best-effort: wp_mail_failed is a global hook, so any plugin's failed wp_mail() call will set $last_mail_error. The trailing edge is controlled — $last_mail_error is cleared immediately after each WooCommerce send — but the leading edge is unbounded: a non-WooCommerce wp_mail_failed fired before a WooCommerce send failure will be attributed to that WooCommerce send. This may produce misleading error reasons in stores where other plugins also call wp_mail().
Method of the class: EmailLogger{}
No Hooks.
Returns
null. Nothing (null).
Usage
$EmailLogger = new EmailLogger(); $EmailLogger->capture_mail_error( $error ): void;
- $error(WP_Error) (required)
- The error returned by wp_mail.
EmailLogger::capture_mail_error() EmailLogger::capture mail error code WC 11.0.1
public function capture_mail_error( WP_Error $error ): void {
$this->last_mail_error = $error->get_error_message();
}