diff --git a/src/Mailer.php b/src/Mailer.php index 306dc5cfed693c827789cdae3b9feafd85b31508..be4ce751772fbfd2040a7c5148c2b53768860779 100644 --- a/src/Mailer.php +++ b/src/Mailer.php @@ -131,16 +131,19 @@ class Mailer { continue; } if ( $email->get_is_enable() ) { + $mailer_from = $this->get_from(); add_filter( 'wp_mail_from', - $from_cb = static function ( $from ) { - return $this->get_from(); + $from_cb = static function ( $from ) use ( $mailer_from ) { + return $mailer_from; } ); + + $mailer_from_name = $this->get_from_name(); add_filter( 'wp_mail_from_name', - $from_name_cb = static function ( $from_name ) { - return $this->get_from_name(); + $from_name_cb = static function ( $from_name ) use ( $mailer_from_name ) { + return $mailer_from_name; } ); add_action( 'wp_mail_failed', [ $this, 'catch_error' ] );