Skip to content
Snippets Groups Projects
Commit 43426991 authored by Piotr Potrebka's avatar Piotr Potrebka
Browse files

feat: mail from

parent ca4eb5a7
No related branches found
No related tags found
1 merge request!2Devel
Pipeline #153494 passed
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -75,24 +75,25 @@ class Mailer {
/** @return void */
public function send() {
foreach ( $this->get_emails() as $email ) {
if ( $email->get_is_enable() ) {
add_filter(
'wp_mail_from',
$from_cb = static function () use ( $email ) {
$from_cb = static function ( $from ) use ( $email ) {
if ( ! empty( $email->get_from() ) ) {
return $email->get_from();
}
return 'wordpress@siteurl.pl';
return $from;
}
);
add_filter(
'wp_mail_from_name',
$from_name_cb = static function () use ( $email ) {
$from_name_cb = static function ( $from_name ) use ( $email ) {
if ( ! empty( $email->get_from_name() ) ) {
return $email->get_from_name();
}
return 'wordpress';
return $from_name;
}
);
add_action( 'wp_mail_failed', [ $this, 'catch_error' ] );
......@@ -122,6 +123,8 @@ class Mailer {
}
}
}
/** @return void */
public function catch_error( WP_Error $error ) {
throw MailerException::with_wp_error( $error );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment