Skip to content

Commit

Permalink
Write email sending errors to the logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kimrutherford committed Mar 15, 2024
1 parent 4ecbd36 commit b056ac4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Canto/MailSender.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use Email::Sender::Simple qw(sendmail);
use Email::MIME;
use Email::Sender::Transport::Sendmail qw();
use Try::Tiny;
use Encode qw(encode);

with 'Canto::Role::Configurable';

Expand Down Expand Up @@ -80,6 +81,8 @@ sub send
return;
}

$body = encode('UTF-8', $body);

my $email = Email::MIME->create(
header=>[To=>$to, From=>$from,
Subject=>$subject],
Expand All @@ -97,11 +100,13 @@ sub send
}

try {
sendmail($email,
my $result = sendmail($email,
{
from => $from,
transport => Email::Sender::Transport::Sendmail->new()
});

warn 'Error from sendmail(): ', Dumper([$result]), "\n";
} catch {
warn qq|Cannot send mail to "$to" with subject "$subject": $_|;
}
Expand Down

0 comments on commit b056ac4

Please sign in to comment.