- my $body;
- $template->process($cfg->{email_template}, \%params, \$body);
-
- Mailer->new(
- from => $cfg->{email_from},
- to => $email_to,
- subject => $cfg->{email_subject},
- content_type => 'text/plain',
- charset => 'utf-8',
- message => Encode::decode('utf-8', $body),
- )->send;
+ eval {
+ my $body;
+ $template->process($cfg->{email_template}, \%params, \$body);
+
+ Mailer->new(
+ from => $cfg->{email_from},
+ to => $email_to,
+ subject => $cfg->{email_subject},
+ content_type => 'text/plain',
+ charset => 'utf-8',
+ message => $body,
+ )->send;
+
+ 1;
+ } or do {
+ debug("Sending a failure notification failed with an exception: $@");
+ };